code: def gradient(self, i):
      global tf, keras
  
      if self.gradients[i] is None:
          if not tf.executing_eagerly():
              out = (
                  self.model_output[:, i]
                  if self.multi_output
                  else self.model_output
              )
              self.gradients[i] = tf.gradients(out, self.model_inputs)
          else:
  
              @tf.function
              def grad_graph(x):
                  phase = tf.keras.backend.learning_phase()
                  tf.keras.backend.set_learning_phase(0)
  
                  with tf.GradientTape(
                      watch_accessed_variables=False
                  ) as tape:
                      tape.watch(x)
                      out = self.model(x)
                      if self.multi_output:
                          out = out[:, i]
  
                  x_grad = tape.gradient(out, x)
  
                  tf.keras.backend.set_learning_phase(phase)
  
                  return x_grad
  
              self.gradients[i] = grad_graph
  
      return self.gradients[i]
  
imports: import warnings
  import numpy
  import pandas
  from packaging import version
  from .._explanation import Explanation
  from ..explainers._explainer import Explainer
  from ..explainers.tf_utils import _get_graph, _get_model_inputs, _get_model_output, _get_session
label_desc: Use image node_id 2 for calling the _TFGradient obj's underlying member method code with example usage: obj.gradient(i) and returns: self, x_grad