code: def fftn_centered_t(
      im: Tensor, spatial_dims: int, is_complex: bool = True
  ) -> Tensor:
      """
      Pytorch-based fft for spatial_dims-dim signals. "centered" means this function automatically takes care
      of the required ifft and fft shifts.
      This is equivalent to do ifft in numpy based on numpy.fft.fftn, numpy.fft.fftshift, and numpy.fft.ifftshift
  
      Args:
          im: image that can be
              1) real-valued: the shape is (C,H,W) for 2D spatial inputs and (C,H,W,D) for 3D, or
              2) complex-valued: the shape is (C,H,W,2) for 2D spatial data and (C,H,W,D,2) for 3D. C is the number of channels.
          spatial_dims: number of spatial dimensions (e.g., is 2 for an image, and is 3 for a volume)
          is_complex: if True, then the last dimension of the input im is expected to be 2 (representing real and imaginary channels)
  
      Returns:
          "out" which is the output kspace (fourier of im)
  
      Example:
  
          .. code-block:: python
  
              import torch
              im = torch.ones(1,3,3,2) # the last dim belongs to real/imaginary parts
              # output1 and output2 will be identical
              output1 = torch.fft.fftn(torch.view_as_complex(torch.fft.ifftshift(im,dim=(-3,-2))), dim=(-2,-1), norm="ortho")
              output1 = torch.fft.fftshift( torch.view_as_real(output1), dim=(-3,-2) )
  
              output2 = fftn_centered(im, spatial_dims=2, is_complex=True)
      """
      # define spatial dims to perform ifftshift, fftshift, and fft
      shift = list(range(-spatial_dims, 0))
      if is_complex:
          if im.shape[-1] != 2:
              raise ValueError(
                  f"img.shape[-1] is not 2 ({im.shape[-1]})."
              )
          shift = list(range(-spatial_dims - 1, -1))
      dims = list(range(-spatial_dims, 0))
  
      x = ifftshift(im, shift)
  
      if is_complex:
          x = torch.view_as_real(
              torch.fft.fftn(
                  torch.view_as_complex(x), dim=dims, norm="ortho"
              )
          )
      else:
          x = torch.view_as_real(
              torch.fft.fftn(x, dim=dims, norm="ortho")
          )
  
      out: Tensor = fftshift(x, shift)
  
      return out
  
file_path: MONAI/monai/networks/blocks/fft_utils_t.py
imports: from __future__ import annotations
  import torch
  from torch import Tensor
label_desc: Use image node_id 6 for calling a global function with example usage: fftn_centered_t(im, spatial_dims, is_complex) and returns: out