code: def testGiantConst(self):
      # Disabling Mlir bridge since using the tf2xla implementation of
      # StridedSliceop which would get exectued in this GiantConst test.
      config.disable_mlir_bridge()
      strategy = get_tpu_strategy()
      types = {
          dtypes.bool,
          dtypes.int8,
          dtypes.int16,
          dtypes.int32,
          dtypes.int64,
          dtypes.uint8,
          dtypes.uint16,
          dtypes.uint32,
          dtypes.uint64,
          dtypes.float16,
          dtypes.bfloat16,
          dtypes.float32,
          dtypes.float64,
      }
      for dtype in types:
          values = [True if dtype is dtypes.bool else 1]
  
          if dtype is dtypes.bool:
              values.append(False)
          elif dtype is not dtypes.float64:
              # TPUs don't follow IEEE 754 float64 standard for 64 bit floating point
              # numbers so it could return different output even with just data
              # transformation ops without any arithmetic operations.
              values.extend([dtype.min, dtype.max])
  
          for value in values:
  
              @def_function.function
              def train_step():
                  # pylint: disable=cell-var-from-loop
                  def computation():
                      const = constant_op.constant(
                          value, dtype=dtype, shape=[1024] * 4
                      )
                      return const[:1, :1, :1, :1]
  
                  return strategy.run(computation, args=())
  
              output = strategy.experimental_local_results(
                  train_step()
              )[0]
              expected = np.full((1, 1, 1, 1), value)
              self.assertAllEqual(output, expected)
  
file_path: tensorflow/tensorflow/compiler/tests/giant_const_op_test.py
imports: import os
  import numpy
  from tensorflow.python.distribute import tpu_strategy
  from tensorflow.python.distribute.cluster_resolver import tpu_cluster_resolver
  from tensorflow.python.eager import def_function
  from tensorflow.python.eager import remote
  from tensorflow.python.eager import test
  from tensorflow.python.framework import config
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.platform import flags
label_desc: Use image node_id 1 for calling the GiantConstOp obj's underlying member method code with example usage: obj.testGiantConst() and returns: strategy, const