code: def caricature(
      img, model, layer, n_steps=512, cossim_pow=0.0, verbose=True
  ):
      if isinstance(layer, str):
          layers = [layer]
      elif isinstance(layer, (tuple, list)):
          layers = layer
      else:
          raise TypeError("layer must be str, tuple or list")
  
      with tf.Graph().as_default(), tf.Session() as sess:
          img = resize(img, model.image_shape[:2])
  
          objective = objectives.Objective.sum(
              [
                  1.0
                  * dot_compare(
                      layer, cossim_pow=cossim_pow, batch=i + 1
                  )
                  for i, layer in enumerate(layers)
              ]
          )
  
          t_input = tf.placeholder(tf.float32, img.shape)
          param_f = param.image(
              img.shape[0],
              decorrelate=True,
              fft=True,
              alpha=False,
              batch=len(layers),
          )
          param_f = tf.concat([t_input[None], param_f], 0)
  
          transforms = transform.standard_transforms + [
              transform.crop_or_pad_to(*model.image_shape[:2])
          ]
  
          T = render.make_vis_T(
              model, objective, param_f, transforms=transforms
          )
          loss, vis_op, t_image = T("loss"), T("vis_op"), T("input")
  
          tf.global_variables_initializer().run()
          for i in range(n_steps):
              _ = sess.run([vis_op], {t_input: img})
  
          result = t_image.eval(feed_dict={t_input: img})
  
      if verbose:
          lucid.misc.io.showing.images(result[1:], layers)
      return result
  
file_path: lucid/lucid/recipes/caricature.py
imports: from os.path import join
  import json
  import numpy
  import tensorflow
  import scipy.ndimage
  import lucid.modelzoo.vision_models
  import lucid.optvis.objectives
  import lucid.optvis.param
  import lucid.optvis.render
  import lucid.optvis.transform
  from lucid.misc.io import show, load, save
  from lucid.misc.io.reading import read
  from lucid.misc.ndimage_utils import resize
  import lucid.misc.io.showing
  from lucid.modelzoo.vision_base import SerializedModel
label_desc: Use image node_id 3 for calling a global function with example usage: caricature(img, model, layer, n_steps, cossim_pow, verbose) and returns: result