class_docstr: To run: "python -m saliency.tf1.integrated_gradients_test" from the top-level directory.
class_docstr_tok: ["To","run",":","``","python","-m","saliency.tf1.integrated_gradients_test","''","from","the","top-level","directory","."]
code: def setUp(self):
      super().setUp()
      with tf.Graph().as_default() as graph:
          x = tf.placeholder(shape=[None, 3], dtype=tf.float32)
          contrib = [5 * x[:, 0], x[:, 1] * x[:, 1], tf.sin(x[:, 2])]
          y = contrib[0] + contrib[1] + contrib[2]
          sess = tf.Session(graph=graph)
          self.sess_spy = mock.MagicMock(wraps=sess)
  
          self.x_baseline_val = np.array([[0.5, 0.8, 1.0]], dtype=float)
          self.x_input_val = np.array([[1.0, 2.0, 3.0]], dtype=float)
  
          # Calculate the value of `contrib` at the baseline and input. `y` is
          # the sum of contrib and each variable is independent, so the expected
          # contribution is equal to the difference between the baseline and input
          # contribution for each.
          contrib_baseline_val = sess.run(
              contrib, feed_dict={x: self.x_baseline_val}
          )
          contrib_input_val = sess.run(
              contrib, feed_dict={x: self.x_input_val}
          )
          self.expected_val = np.array(contrib_input_val) - np.array(
              contrib_baseline_val
          )
          self.expected_val = self.expected_val.flatten()
  
          self.ig_instance = integrated_gradients.IntegratedGradients(
              graph, self.sess_spy, y, x
          )
  
file_path: saliency/saliency/tf1/integrated_gradients_test.py
imports: import unittest
  import unittest.mock
  from .None import integrated_gradients
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 1 for calling the IntegratedGradientsTest obj's underlying member method code with example usage: obj.setUp() without return types