code: def cast_to_numpy(dtype: type_utils.TfdsDType) -> np.dtype:
      """Casts any np.dtype or tf.dtypes.DType to np.dtype.
  
      Args:
        dtype: input DType.
  
      Returns:
        Equivalent NumPy DType.
      """
      tf_already_loaded = enp.lazy.has_tf
      if tf_already_loaded and isinstance(dtype, tf.dtypes.DType):
          np_dtype = np.dtype(dtype.as_numpy_dtype)
          logging.log_first_n(
              logging.WARNING,
              (
                  f"You use TensorFlow DType {dtype} in tfds.features "
                  "This will soon be deprecated in favor of NumPy DTypes. "
                  f"In the meantime it was converted to {np_dtype}."
              ),
              10,
          )
          return np_dtype
      # Strings are managed as np.object_ (rather than np.str_) in order to
      # optimize for memory and for consistency with tf.string:
      # np.array(['', '1234567890'], dtype=np.str_).nbytes == 80
      # np.array(['', '1234567890'], dtype=np.object_).nbytes == 16
      if is_string(dtype):
          return np.dtype(np.object_)
      return cast(np.dtype, dtype)
  
file_path: datasets/tensorflow_datasets/core/utils/dtype_utils.py
imports: from typing import cast, Any, List, Type, Union
  from absl import logging
  from etils import enp
  import numpy
  from tensorflow_datasets.core.utils import py_utils
  from tensorflow_datasets.core.utils import type_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
label_desc: Use image node_id 1 for calling a global function with example usage: cast_to_numpy(dtype) and returns: cast, np_dtype, np