code: def _constant_eager_impl(
      ctx, value, dtype, shape, verify_shape
  ) -> ops._EagerTensorBase:
      """Creates a constant on the current device."""
      t = convert_to_eager_tensor(value, ctx, dtype)
      if shape is None:
          return t
      shape = tensor_shape.as_shape(shape)
      if shape == t.shape:
          return t
      if verify_shape:
          raise TypeError(
              f"Expected Tensor {t} (converted from {value}) with shape "
              f"{tuple(shape)}, but got shape {tuple(t.shape)}."
          )
      num_t = t.shape.num_elements()
      # TODO(josh11b): Implement shape -> eager tensor conversion.
      if num_t == shape.num_elements():
          return _eager_reshape(t, shape.as_list(), ctx)
      if num_t == 1:
          if t.dtype == dtypes.bool:
              # We don't have a Fill kernel for bool dtype on GPU. So we first run
              # Fill on CPU and then copy to GPU if needed.
              with ops.device("/device:CPU:0"):
                  x = _eager_fill(
                      shape.as_list(), _eager_identity(t, ctx), ctx
                  )
              return _eager_identity(x, ctx)
          else:
              return _eager_fill(shape.as_list(), t, ctx)
      raise TypeError(
          "Eager execution of tf.constant with unsupported shape. "
          f"Tensor {t} (converted from {value}) has {num_t:d} "
          f"elements, but got `shape` {shape} with "
          f"{shape.num_elements()} elements)."
      )
  
imports: from typing import Union
  import numpy
  from tensorflow.core.framework import types_pb2
  from tensorflow.core.protobuf import struct_pb2
  from tensorflow.python.eager import context
  from tensorflow.python.eager import execute
  from tensorflow.python.framework import constant_tensor_conversion
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.framework import tensor_conversion_registry
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.profiler import trace
  from tensorflow.python.saved_model import nested_structure_coder
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 8 for calling a global function with example usage: _constant_eager_impl(ctx, value, dtype, shape, verify_shape) and returns: t, t, _eager_reshape, _eager_identity, _eager_fill