code: def testTensorArrayScatterReadAndGradients(self):
      with self.session() as session, self.test_scope():
          id0 = array_ops.placeholder(dtypes.int32)
          id1 = array_ops.placeholder(dtypes.int32)
  
          def fn():
              ta = tensor_array_ops.TensorArray(
                  dtype=dtypes.float32, tensor_array_name="foo", size=10
              )
  
              indices = constant_op.constant([1, 8])
              value = constant_op.constant([[1.0, -1.0], [10.0, -10.0]])
  
              w = ta.scatter(indices, value)
              r0 = w.read(id0)
              r1 = w.read(id1)
  
              # Test combined gradients + aggregation of read(0).
              grad = gradients_impl.gradients(
                  ys=[r0, r1],
                  xs=[value],
                  grad_ys=[[2.0, 3.0], [4.0, 5.0]],
              )
              return [[r0, r1], grad]
  
          read_vals, grad_vals = session.run(
              xla.compile(fn), feed_dict={id0: 1, id1: 8}
          )
  
          self.assertEqual(len(read_vals), 2)
          self.assertEqual(len(grad_vals), 1)
          self.assertAllEqual([1.0, -1.0], read_vals[0])
          self.assertAllEqual([10.0, -10.0], read_vals[1])
          self.assertAllEqual([[2.0, 3.0], [4.0, 5.0]], grad_vals[0])
  
imports: import numpy
  from tensorflow.compiler.tests import xla_test
  from tensorflow.python.compiler.xla import xla
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_util
  from tensorflow.python.ops import gen_data_flow_ops
  from tensorflow.python.ops import gradients_impl
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import tensor_array_grad
  from tensorflow.python.ops import tensor_array_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
label_desc: Use image node_id 42 for calling the TensorArrayTest obj's underlying member method code with example usage: obj.testTensorArrayScatterReadAndGradients() and returns: list