code: def py_func_grad(
      func, inp, Tout, stateful=True, name=None, grad=None
  ):
      """Custom py_func with gradient support"""
      # Need to generate a unique name to avoid duplicates:
      rnd_name = "PyFuncGrad" + str(np.random.randint(0, 1e8))
  
      tf.RegisterGradient(rnd_name)(grad)
      g = tf.get_default_graph()
      with g.gradient_override_map(
          {"PyFunc": rnd_name, "PyFuncStateless": rnd_name}
      ):
          return tf.py_func(
              func, inp, Tout, stateful=stateful, name=name
          )
  
file_path: cleverhans/cleverhans_v3.1.0/examples/robust_vision_benchmark/cleverhans_attack_example/utils.py
imports: import cleverhans.model
  import tensorflow
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: py_func_grad(func, inp, Tout, stateful, name, grad) and returns: tf