code: def test_param_can_fit_image(param, test_image, maxsteps=1000):
      shape = (1,) + test_image.shape
      with tf.Session() as sess:
          image_param_t = param(shape)
          image_t = to_valid_rgb(image_param_t)
          loss_t = tf.reduce_mean((image_t - test_image) ** 2)
          dist_t = tf.reduce_mean(tf.abs(image_t - test_image))
  
          optimizer = tf.train.AdamOptimizer(0.05)
          optimize_op = optimizer.minimize(loss_t)
  
          tf.global_variables_initializer().run()
          for step in range(maxsteps):
              mean_distance, _ = sess.run([dist_t, optimize_op])
              if mean_distance < 0.01:
                  break
      assert mean_distance < 0.01
  
file_path: lucid/tests/optvis/param/test_spatial.py
imports: from __future__ import absolute_import, division, print_function
  import pytest
  import numpy
  import tensorflow
  from lucid.misc.io import load
  from lucid.optvis.param.color import to_valid_rgb
  from lucid.optvis.param.spatial import pixel_image, fft_image, laplacian_pyramid_image, bilinearly_sampled_image
label_desc: Use image node_id 2 for calling a global function with example usage: test_param_can_fit_image(param, test_image, maxsteps) without return types