class_docstr: Perform Integrated Gradients algorithm for a given input
  
  Paper: [Axiomatic Attribution for Deep Networks](https://arxiv.org/pdf/1703.01365.pdf)
class_docstr_tok: ["Perform","Integrated","Gradients","algorithm","for","a","given","input","Paper",":","[","Axiomatic","Attribution","for","Deep","Networks","]","(","https",":","\/\/arxiv.org\/pdf\/1703.01365.pdf",")"]
docstr: Perform backpropagation to compute integrated gradients.
  
  Args:
      interpolated_images (numpy.ndarray): 4D-Tensor of shape (N * n_steps, H, W, 3)
      model (tf.keras.Model): tf.keras model to inspect
      class_index (int): Index of targeted class
      n_steps (int): Number of steps in the path
  
  Returns:
      tf.Tensor: 4D-Tensor of shape (N, H, W, 3) with integrated gradients
docstr_tok: ["Perform","backpropagation","to","compute","integrated","gradients",".","Args",":","interpolated_images","(","numpy.ndarray",")",":","4D-Tensor","of","shape","(","N","*","n_steps",",","H",",","W",",","3",")","model","(","tf.keras.Model",")",":","tf.keras","model","to","inspect","class_index","(","int",")",":","Index","of","targeted","class","n_steps","(","int",")",":","Number","of","steps","in","the","path","Returns",":","tf.Tensor",":","4D-Tensor","of","shape","(","N",",","H",",","W",",","3",")","with","integrated","gradients"]
code: def get_integrated_gradients(
      interpolated_images, model, class_index, n_steps
  ):
      """
      Perform backpropagation to compute integrated gradients.
  
      Args:
          interpolated_images (numpy.ndarray): 4D-Tensor of shape (N * n_steps, H, W, 3)
          model (tf.keras.Model): tf.keras model to inspect
          class_index (int): Index of targeted class
          n_steps (int): Number of steps in the path
  
      Returns:
          tf.Tensor: 4D-Tensor of shape (N, H, W, 3) with integrated gradients
      """
      with tf.GradientTape() as tape:
          inputs = tf.cast(interpolated_images, tf.float32)
          tape.watch(inputs)
          predictions = model(inputs)
          loss = predictions[:, class_index]
  
      grads = tape.gradient(loss, inputs)
      grads_per_image = tf.reshape(
          grads, (-1, n_steps, *grads.shape[1:])
      )
  
      integrated_gradients = tf.reduce_mean(grads_per_image, axis=1)
  
      return integrated_gradients
  
file_path: tf-explain/tf_explain/core/integrated_gradients.py
imports: import numpy
  import tensorflow
  from tf_explain.utils.display import grid_display
  from tf_explain.utils.image import transform_to_normalized_grayscale
  from tf_explain.utils.saver import save_grayscale
label_desc: Use image node_id 2 for calling the IntegratedGradients obj's underlying member method code with example usage: obj.get_integrated_gradients(interpolated_images, model, class_index, n_steps) and returns: integrated_gradients