parameters: (value_or_tensor_or_var, dtype=None)
return_statement: return value
docstring: 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.
docstring_summary: Returns value if value_or_tensor_or_var has a constant value.
docstring_tokens: Returns value if value_or_tensor_or_var has a constant value .
function: 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
function_tokens: def constant_value ( value_or_tensor_or_var , dtype = None ) : 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