code: def _testTensorArrayWriteGradientAddMultipleAdds(self, dtype):
      with self.session(), self.test_scope():
          c = lambda x: np.asarray(x, dtype=dtype.as_numpy_dtype)
  
          def fn():
              ta = tensor_array_ops.TensorArray(
                  dtype=dtype,
                  tensor_array_name="foo",
                  size=3,
                  infer_shape=False,
              )
  
              w0 = ta.write(2, c(3.0))
              w1 = w0.write(2, c(4.0))
  
              ta_grad = w1.grad("grad")
  
              w0_grad = ta_grad.write(2, c(3.0))
              w1_grad = w0_grad.write(2, c(4.0))
              w2_grad = w1_grad.write(2, c(5.0))
  
              return w2_grad.read(2)
  
          # Assert that aggregation works correctly
          self.assertAllEqual(c(12.00), xla.compile(fn)[0])
  
          def fn():
              ta = tensor_array_ops.TensorArray(
                  dtype=dtype,
                  tensor_array_name="foo",
                  size=3,
                  infer_shape=False,
              )
  
              w0 = ta.write(2, c(3.0))
              w1 = w0.write(2, c(4.0))
  
              ta_grad = w1.grad("grad")
              # Using differing shapes causes an exception
              wb0_grad = ta_grad.write(1, c(1.0))
              wb1_grad = wb0_grad.write(1, c([1.0]))
  
              return wb1_grad.flow
  
          with self.assertRaisesOpError(
              r"Mismatched TensorArray sizes"
          ):
              xla.compile(fn)[0].eval()
  
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 18 for calling the TensorArrayTest obj's underlying member method code with example usage: obj._testTensorArrayWriteGradientAddMultipleAdds(dtype) and returns: w2_grad, wb1_grad