code: def test_constant_unallowed_promotion(self):
      # If promotion is unsuccessful, it should throw the original error message
      # when the input tensor's dtype != dtype arg.
      a = constant_op.constant(5, dtypes.float32)
      with self.assertRaisesRegex(
          TypeError,
          "Expected tensor 5.0 with dtype tf.int32, but got dtype tf.float32.",
      ):
          _ = constant_op.constant(a, dtypes.int32)
  
      with self.assertRaisesRegex(
          TypeError, "Cannot convert 5.0 to EagerTensor of dtype int32"
      ):
          _ = constant_op.constant(5.0, dtypes.int32)
  
      a = constant_op.constant(5.0)
      with self.assertRaisesRegex(
          TypeError,
          "Expected tensor 5.0 with dtype tf.int32, but got dtype tf.float32.",
      ):
          _ = constant_op.constant(a, dtypes.int32)
  
imports: from absl.testing import parameterized
  import numpy
  from google.protobuf import text_format
  from tensorflow.core.framework import graph_pb2
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import flexible_dtypes
  from tensorflow.python.framework import importer
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.framework import test_util
  from tensorflow.python.framework.weak_tensor import WeakTensor
  from tensorflow.python.ops import gradients_impl
  from tensorflow.python.ops import weak_tensor_ops
  from tensorflow.python.ops import weak_tensor_test_util
  from tensorflow.python.ops.parallel_for import control_flow_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 5 for calling the WeakTensorConstantOpTest obj's underlying member method code with example usage: obj.test_constant_unallowed_promotion() without return types