code: def testTensorArrayReadWrongIndexOrDataTypeFails(self):
      # Find two different floating point types, create an array of
      # the first type, but try to read the other type.
      if len(self.float_types) > 1:
          dtype1, dtype2 = list(self.float_types)[:2]
          with self.session(), self.test_scope():
  
              def fn():
                  ta = tensor_array_ops.TensorArray(
                      dtype=dtype1, tensor_array_name="foo", size=3
                  )
  
                  w0 = ta.write(0, math_ops.cast([[4.0, 5.0]], dtype1))
  
                  # Test reading wrong datatype.
                  return gen_data_flow_ops.tensor_array_read_v3(
                      handle=w0.handle,
                      index=0,
                      dtype=dtype2,
                      flow_in=w0.flow,
                  )
  
              with self.assertRaisesOpError("TensorArray dtype is "):
                  self.evaluate(xla.compile(fn))
  
              def fn():
                  ta = tensor_array_ops.TensorArray(
                      dtype=dtype1, tensor_array_name="foo", size=3
                  )
  
                  w0 = ta.write(0, math_ops.cast([[4.0, 5.0]], dtype1))
  
                  # Test reading from a different index than the one we wrote to
                  with ops.control_dependencies([w0.read(1)]):
                      return 1.0
  
              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 16 for calling the TensorArrayTest obj's underlying member method code with example usage: obj.testTensorArrayReadWrongIndexOrDataTypeFails() and returns: gen_data_flow_ops, int