code: def nonlinearity_2d_handler(
      input_ind0, input_ind1, op_func, explainer, op, *grads
  ):
      if not (input_ind0 == 0 and input_ind1 == 1):
          emsg = (
              "TODO: Can't yet handle double inputs that are not first!"
          )
          raise Exception(emsg)
      xout, rout = tf.split(op.outputs[0], 2)
      in0 = op.inputs[input_ind0]
      in1 = op.inputs[input_ind1]
      xin0, rin0 = tf.split(in0, 2)
      xin1, rin1 = tf.split(in1, 2)
      delta_in0 = xin0 - rin0
      delta_in1 = xin1 - rin1
      dup0 = [2] + [1 for i in delta_in0.shape[1:]]
      out10 = op_func(xin0, rin1)
      out01 = op_func(rin0, xin1)
      out11, out00 = xout, rout
      out0 = 0.5 * (out11 - out01 + out10 - out00)
      out0 = grads[0] * tf.tile(out0 / delta_in0, dup0)
      out1 = 0.5 * (out11 - out10 + out01 - out00)
      out1 = grads[0] * tf.tile(out1 / delta_in1, dup0)
  
      # Avoid divide by zero nans
      out0 = tf.where(
          tf.abs(tf.tile(delta_in0, dup0)) < 1e-7,
          tf.zeros_like(out0),
          out0,
      )
      out1 = tf.where(
          tf.abs(tf.tile(delta_in1, dup0)) < 1e-7,
          tf.zeros_like(out1),
          out1,
      )
  
      # see if due to broadcasting our gradient shapes don't match our input shapes
      if np.any(np.array(out1.shape) != np.array(in1.shape)):
          broadcast_index = np.where(
              np.array(out1.shape) != np.array(in1.shape)
          )[0][0]
          out1 = tf.reduce_sum(
              out1, axis=broadcast_index, keepdims=True
          )
      elif np.any(np.array(out0.shape) != np.array(in0.shape)):
          broadcast_index = np.where(
              np.array(out0.shape) != np.array(in0.shape)
          )[0][0]
          out0 = tf.reduce_sum(
              out0, axis=broadcast_index, keepdims=True
          )
  
      return [out0, out1]
  
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 12 for calling a global function with example usage: nonlinearity_2d_handler(input_ind0, input_ind1, op_func, explainer, op) and returns: list