code: def fftshift(x, axes=None):
      """
      Shift the zero-frequency component to the center of the spectrum.
  
      This function swaps half-spaces for all axes listed (defaults to all).
      Note that ``y[0]`` is the Nyquist component only if ``len(x)`` is even.
  
      Parameters
      ----------
      x : array_like
          Input tensor.
      axes : int or shape tuple, optional
          Axes over which to shift.  Default is None, which shifts all axes.
  
      Returns
      -------
      y : Tensor
          The shifted tensor.
  
      See Also
      --------
      ifftshift : The inverse of `fftshift`.
  
      Examples
      --------
      >>> import mars.tensor as mt
  
      >>> freqs = mt.fft.fftfreq(10, 0.1)
      >>> freqs.execute()
      array([ 0.,  1.,  2.,  3.,  4., -5., -4., -3., -2., -1.])
      >>> mt.fft.fftshift(freqs).execute()
      array([-5., -4., -3., -2., -1.,  0.,  1.,  2.,  3.,  4.])
  
      Shift the zero-frequency component only along the second axis:
  
      >>> freqs = mt.fft.fftfreq(9, d=1./9).reshape(3, 3)
      >>> freqs.execute()
      array([[ 0.,  1.,  2.],
             [ 3.,  4., -4.],
             [-3., -2., -1.]])
      >>> mt.fft.fftshift(freqs, axes=(1,)).execute()
      array([[ 2.,  0.,  1.],
             [-4.,  3.,  4.],
             [-1., -3., -2.]])
  
      """
      x = astensor(x)
      dtype = np.fft.fftshift(
          np.empty((1,) * max(1, x.ndim), dtype=x.dtype)
      ).dtype
      axes = TensorFFTShift._process_axes(x, axes)
      op = TensorFFTShift(axes=axes, dtype=dtype)
      return op(x)
  
file_path: mars/mars/tensor/fft/fftshift.py
imports: import numpy
  from ...None import opcodes
  from ..datasource import tensor
  from .core import TensorFFTShiftMixin, TensorFFTShiftBase
label_desc: Use image node_id 1 for calling a global function with example usage: fftshift(x, axes) and returns: op