code: def assert_gradient_ascent(
      objective, model, batch=None, alpha=False, shape=None
  ):
      with tf.Graph().as_default() as graph, tf.Session() as sess:
          shape = shape or [1, 32, 32, 3]
          t_input = param.image(
              shape[1], h=shape[2], batch=batch, alpha=alpha
          )
          if alpha:
              t_input = transform.collapse_alpha_random()(t_input)
          model.import_graph(
              t_input, scope="import", forget_xy_shape=True
          )
  
          def T(layer):
              if layer == "input":
                  return t_input
              if layer == "labels":
                  return model.labels
              return graph.get_tensor_by_name("import/%s:0" % layer)
  
          loss_t = objective(T)
          opt_op = tf.train.AdamOptimizer(0.1).minimize(-loss_t)
          tf.global_variables_initializer().run()
          start_value = sess.run([loss_t])
          for _ in range(NUM_STEPS):
              _ = sess.run([opt_op])
          (end_value,) = sess.run([loss_t])
          print(start_value, end_value)
          assert start_value < end_value
  
imports: from __future__ import absolute_import, division, print_function
  import pytest
  import tensorflow
  import numpy
  from lucid.optvis import objectives, param, render, transform
  from lucid.modelzoo.vision_models import InceptionV1
label_desc: Use image node_id 2 for calling a global function with example usage: assert_gradient_ascent(objective, model, batch, alpha, shape) and returns: graph, t_input, model