docstr: Calculates the gradients for each output with respect to each input.
  Args:
      input_tensor: An input tensor of shape [None, ...] where ...
                    indicates the input dimensions. This function will throw an
                    error if input_tensor is of type list.
      output_tensor: A tensor indicating the output of the model. Should be shaped as
                     [None, num_classes] where None indicates the batch dimension
                     and num_classes is the number of output classes of the model.
  Returns:
      A tensor of shape [None, num_classes, ...], where the ... indicates the input dimensions.
code: def _grad_across_multi_output(
      self, output_tensor, input_tensor, sparse_labels_op=None
  ):
      """
      Calculates the gradients for each output with respect to each input.
      Args:
          input_tensor: An input tensor of shape [None, ...] where ...
                        indicates the input dimensions. This function will throw an
                        error if input_tensor is of type list.
          output_tensor: A tensor indicating the output of the model. Should be shaped as
                         [None, num_classes] where None indicates the batch dimension
                         and num_classes is the number of output classes of the model.
      Returns:
          A tensor of shape [None, num_classes, ...], where the ... indicates the input dimensions.
      """
      if sparse_labels_op is not None:
          sample_indices = tf.range(tf.shape(output_tensor)[0])
  
          indices_tensor = tf.stack(
              [sample_indices, tf.cast(sparse_labels_op, tf.int32)],
              axis=1,
          )
  
          class_selected_output_tensor = tf.gather_nd(
              output_tensor, indices_tensor
          )
  
          class_selected_output_tensor.set_shape([None])
          grad_tensor = tf.gradients(
              class_selected_output_tensor, input_tensor
          )[0]
          return grad_tensor
      else:
          output_class_tensors = tf.unstack(output_tensor, axis=1)
          grad_tensors = []
          for output_class_tensor in output_class_tensors:
              grad_tensor = tf.gradients(
                  output_class_tensor, input_tensor
              )[0]
              grad_tensors.append(grad_tensor)
          multi_grad_tensor = tf.stack(grad_tensors, axis=1)
          return multi_grad_tensor
  
file_path: attributionpriors/attributionpriors/ops.py
imports: import tensorflow
  import numpy
label_desc: Use image node_id 3 for calling the AttributionPriorExplainer obj's underlying member method code with example usage: obj._grad_across_multi_output(output_tensor, input_tensor, sparse_labels_op) and returns: grad_tensor, multi_grad_tensor