I guess you might be missing the import torch.fft statement and thus torch.fft.fftn will raise an error.
>>> import torch
tor>>> torch.__version__
'1.7.1'
>>> torch.fft.fftn
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'builtin_function_or_method' object has no attribute 'fftn'

>>> import torch.fft
>>> torch.fft.fftn
<built-in function fft_fftn>