code: def custom_record_gradient(op_name, inputs, attrs, results):
      """This overrides tensorflow.python.eager.backprop._record_gradient.
  
      We need to override _record_gradient in order to get gradient backprop to
      get called for ResourceGather operations. In order to make this work we
      temporarily "lie" about the input type to prevent the node from getting
      pruned from the gradient backprop process. We then reset the type directly
      afterwards back to what it was (an integer type).
      """
      reset_input = False
      if op_name == "ResourceGather" and inputs[1].dtype == tf.int32:
          inputs[1].__dict__["_dtype"] = tf.float32
          reset_input = True
      try:
          out = tf_backprop._record_gradient(
              "shap_" + op_name, inputs, attrs, results
          )
      except AttributeError:
          out = tf_backprop.record_gradient(
              "shap_" + op_name, inputs, attrs, results
          )
  
      if reset_input:
          inputs[1].__dict__["_dtype"] = tf.int32
  
      return 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 1 for calling a global function with example usage: custom_record_gradient(op_name, inputs, attrs, results) and returns: out