code: def fft_image(shape, sd=None, decay_power=1):
      """An image paramaterization using 2D Fourier coefficients."""
  
      sd = sd or 0.01
      batch, h, w, ch = shape
      freqs = rfft2d_freqs(h, w)
      init_val_size = (2, batch, ch) + freqs.shape
  
      init_val = np.random.normal(size=init_val_size, scale=sd).astype(
          np.float32
      )
      spectrum_real_imag_t = tf.Variable(init_val)
      spectrum_t = tf.complex(
          spectrum_real_imag_t[0], spectrum_real_imag_t[1]
      )
  
      # Scale the spectrum. First normalize energy, then scale by the square-root
      # of the number of pixels to get a unitary transformation.
      # This allows to use similar leanring rates to pixel-wise optimisation.
      scale = 1.0 / np.maximum(freqs, 1.0 / max(w, h)) ** decay_power
      scale *= np.sqrt(w * h)
      scaled_spectrum_t = scale * spectrum_t
  
      # convert complex scaled spectrum to shape (h, w, ch) image tensor
      # needs to transpose because irfft2d returns channels first
      image_t = tf.transpose(
          tf.signal.irfft2d(scaled_spectrum_t), (0, 2, 3, 1)
      )
  
      # in case of odd spatial input dimensions we need to crop
      image_t = image_t[:batch, :h, :w, :ch]
      image_t = image_t / 4.0  # TODO: is that a magic constant?
      return image_t
  
file_path: lucid/lucid/optvis/param/spatial.py
imports: import warnings
  import numpy
  import tensorflow
  from lucid.optvis.param.lowres import lowres_tensor
label_desc: Use image node_id 3 for calling a global function with example usage: fft_image(shape, sd, decay_power) and returns: image_t