code: def _get_np_dtype(spec):
      if not isinstance(
          spec, (tensor_spec.TensorSpec, array_spec.ArraySpec)
      ):
          return None
      dtype = spec.dtype
      if isinstance(dtype, tf.dtypes.DType):
          dtype = dtype.as_numpy_dtype()
      return np.dtype(dtype)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import pprint
  from typing import NamedTuple, Optional
  import numpy
  import tensorflow
  from tf_agents.specs import array_spec
  from tf_agents.specs import tensor_spec
  from tf_agents.typing import types
label_desc: Use image node_id 2 for calling a global function with example usage: _get_np_dtype(spec) and returns: np, None