code: def constant_value(value_or_tensor_or_var, dtype=None):
      """Returns value if value_or_tensor_or_var has a constant value.
  
      Args:
        value_or_tensor_or_var: A value, a `Tensor` or a `Variable`.
        dtype: Optional `tf.dtype`, if set it would check it has the right
          dtype.
  
      Returns:
        The constant value or None if it not constant.
  
      Raises:
        ValueError: if value_or_tensor_or_var is None or the tensor_variable has the
        wrong dtype.
      """
      if value_or_tensor_or_var is None:
          raise ValueError("value_or_tensor_or_var cannot be None")
      value = value_or_tensor_or_var
      if isinstance(
          value_or_tensor_or_var, (ops.Tensor, variables.Variable)
      ):
          if dtype and value_or_tensor_or_var.dtype != dtype:
              raise ValueError(
                  "It has the wrong type %s instead of %s"
                  % (value_or_tensor_or_var.dtype, dtype)
              )
          if isinstance(value_or_tensor_or_var, variables.Variable):
              value = None
          else:
              value = tensor_util.constant_value(value_or_tensor_or_var)
      return value
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from collections import namedtuple
  from collections import OrderedDict
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import variables
label_desc: Use image node_id 6 for calling a global function with example usage: constant_value(value_or_tensor_or_var, dtype) and returns: value