class_docstr: Using tf.gradients to implement the backpropagation was
  inspired by the gradient-based implementation approach proposed by Ancona et al, ICLR 2018. Note
  that this package does not currently use the reveal-cancel rule for ReLu units proposed in DeepLIFT.
class_docstr_tok: ["Using","tf.gradients","to","implement","the","backpropagation","was","inspired","by","the","gradient-based","implementation","approach","proposed","by","Ancona","et","al",",","ICLR","2018",".","Note","that","this","package","does","not","currently","use","the","reveal-cancel","rule","for","ReLu","units","proposed","in","DeepLIFT","."]
code: def execute_with_overridden_gradients(self, f):
      # replace the gradients for all the non-linear activations
      # we do this by hacking our way into the registry (TODO: find a public API for this if it exists)
      reg = tf_ops._gradient_registry._registry
      ops_not_in_registry = ["TensorListReserve"]
      # NOTE: location_tag taken from tensorflow source for None type ops
      location_tag = (
          "UNKNOWN",
          "UNKNOWN",
          "UNKNOWN",
          "UNKNOWN",
          "UNKNOWN",
      )
      # TODO: unclear why some ops are not in the registry with TF 2.0 like TensorListReserve
      for non_reg_ops in ops_not_in_registry:
          reg[non_reg_ops] = {"type": None, "location": location_tag}
      for n in op_handlers:
          if n in reg:
              self.orig_grads[n] = reg[n]["type"]
              reg["shap_" + n] = {
                  "type": self.custom_grad,
                  "location": reg[n]["location"],
              }
              reg[n]["type"] = self.custom_grad
  
      # In TensorFlow 1.10 they started pruning out nodes that they think can't be backpropped
      # unfortunately that includes the index of embedding layers so we disable that check here
      if hasattr(tf_gradients_impl, "_IsBackpropagatable"):
          orig_IsBackpropagatable = (
              tf_gradients_impl._IsBackpropagatable
          )
          tf_gradients_impl._IsBackpropagatable = lambda tensor: True
  
      # define the computation graph for the attribution values using a custom gradient-like computation
      try:
          out = f()
      finally:
          # reinstate the backpropagatable check
          if hasattr(tf_gradients_impl, "_IsBackpropagatable"):
              tf_gradients_impl._IsBackpropagatable = (
                  orig_IsBackpropagatable
              )
  
          # restore the original gradient definitions
          for n in op_handlers:
              if n in reg:
                  del reg["shap_" + n]
                  reg[n]["type"] = self.orig_grads[n]
          for non_reg_ops in ops_not_in_registry:
              del reg[non_reg_ops]
      if not tf.executing_eagerly():
          return out
      else:
          return [v.numpy() for v in out]
  
imports: import warnings
  import numpy
  from packaging import version
  from ...utils._exceptions import DimensionError
  from .._explainer import Explainer
  from ..tf_utils import _get_graph, _get_model_inputs, _get_model_output, _get_session
  from .deep_utils import _check_additivity
label_desc: Use image node_id 9 for calling the TFDeep obj's underlying member method code with example usage: obj.execute_with_overridden_gradients(f) and returns: out, unknown