docstr: Tests that copies of unsupported types don't crash.
docstr_tok: ["Tests","that","copies","of","unsupported","types","do","n't","crash","."]
code: def testCopiesOfUnsupportedTypesFailGracefully(self):
      """Tests that copies of unsupported types don't crash."""
      test_types = set(
          [
              np.uint8,
              np.uint16,
              np.uint32,
              np.uint64,
              np.int8,
              np.int16,
              np.int32,
              np.int64,
              np.float16,
              np.float32,
              np.float16,
              dtypes.bfloat16.as_numpy_dtype,
          ]
      )
      shape = (10, 10)
      for unsupported_dtype in test_types - self.all_types:
          with self.session() as sess:
              with ops.device("CPU"):
                  x = array_ops.placeholder(unsupported_dtype, shape)
              with self.test_scope():
                  (y,) = array_ops.identity_n([x])
              with ops.device("CPU"):
                  z = array_ops.identity(y)
  
                  inputs = np.random.randint(-100, 100, shape)
                  inputs = inputs.astype(unsupported_dtype)
                  # Execution should either succeed or raise an InvalidArgumentError,
                  # but not crash. Even "unsupported types" may succeed here since some
                  # backends (e.g., the CPU backend) are happy to handle buffers of
                  # unsupported types, even if they cannot compute with them.
                  try:
                      sess.run(z, {x: inputs})
                  except errors.InvalidArgumentError:
                      pass
  
file_path: tensorflow-upstream/tensorflow/compiler/tests/xla_device_test.py
imports: import numpy
  from tensorflow.compiler.tests import xla_test
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gen_control_flow_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 2 for calling the XlaDeviceTest obj's underlying member method code with example usage: obj.testCopiesOfUnsupportedTypesFailGracefully() without return types