parameters: (type_value)
docstring: Converts the given `type_value` to a `DType`.
  
    Note: `DType` values are interned. When passed a new `DType` object,
    `as_dtype` always returns the interned value.
  
    Args:
      type_value: A value that can be converted to a `tf.DType` object. This may
        currently be a `tf.DType` object, a [`DataType`
        enum](https://www.tensorflow.org/code/tensorflow/core/framework/types.proto),
          a string type name, or a [`numpy.dtype`](https://numpy.org/doc/stable/reference/generated/numpy.dtype.html).
  
    Returns:
      A `DType` corresponding to `type_value`.
  
    Raises:
      TypeError: If `type_value` cannot be converted to a `DType`.
docstring_summary: Converts the given `type_value` to a `DType`.
docstring_tokens: Converts the given type_value to a DType .
function: def as_dtype(type_value):
    """Converts the given `type_value` to a `DType`.
  
    Note: `DType` values are interned. When passed a new `DType` object,
    `as_dtype` always returns the interned value.
  
    Args:
      type_value: A value that can be converted to a `tf.DType` object. This may
        currently be a `tf.DType` object, a [`DataType`
        enum](https://www.tensorflow.org/code/tensorflow/core/framework/types.proto),
          a string type name, or a [`numpy.dtype`](https://numpy.org/doc/stable/reference/generated/numpy.dtype.html).
  
    Returns:
      A `DType` corresponding to `type_value`.
  
    Raises:
      TypeError: If `type_value` cannot be converted to a `DType`.
    """
    if isinstance(type_value, DType):
      return _INTERN_TABLE[type_value.as_datatype_enum]
  
    if isinstance(type_value, np.dtype):
      try:
        return _NP_TO_TF[type_value.type]
      except KeyError:
        pass
  
    try:
      return _ANY_TO_TF[type_value]
    except (KeyError, TypeError):
      # TypeError indicates that type_value is not hashable.
      pass
  
    if hasattr(type_value, "dtype"):
      try:
        return _NP_TO_TF[np.dtype(type_value.dtype).type]
      except (KeyError, TypeError):
        pass
  
    if isinstance(type_value, _dtypes.DType):
      return _INTERN_TABLE[type_value.as_datatype_enum]
  
    raise TypeError(f"Cannot convert the argument `type_value`: {type_value!r} "
                    "to a TensorFlow DType.")
function_tokens: def as_dtype ( type_value ) : if isinstance ( type_value , DType ) : return _INTERN_TABLE [ type_value . as_datatype_enum ] if isinstance ( type_value , np . dtype ) : try : return _NP_TO_TF [ type_value . type ] except KeyError : pass try : return _ANY_TO_TF [ type_value ] except ( KeyError , TypeError ) : # TypeError indicates that type_value is not hashable. pass if hasattr ( type_value , "dtype" ) : try : return _NP_TO_TF [ np . dtype ( type_value . dtype ) . type ] except ( KeyError , TypeError ) : pass if isinstance ( type_value , _dtypes . DType ) : return _INTERN_TABLE [ type_value . as_datatype_enum ] raise TypeError ( f"Cannot convert the argument `type_value`: {type_value!r} " "to a TensorFlow DType." )