Hey @micklexqg,
If you check out the torch.fft 18 documentation you will discover that it expects a tensor with signal_dim + 1 dimensions, where the last axis is expected to be of size 2. This is because the input is expected to be complex-valued. The last axis, therefore, needs to hold both the real and complex coefficients.
I am going to assume you only have real-valued input, in which case you should torch.rfft 6 instead. This function expects an input tensor with signal_dim dimensions. Note also that the second argument to both torch.fft and torch.rfft is the signal_dim, which must be set to either 1, 2, or 3.
I have not tested this, but the following version of your example should work as expected;
FL = torch.rfft(f, 3) / torch.sqrt(M * N)  # f is a torch.FloatTensor[1, 3, 400, 300]

Although this tensor has  4 dimensions, the first is considered the batch dimension not considered part of the “signal dimensions”. This is noted in the documentation.