code: def _as_array(a, t=np.float32):
      if t is None:
          t = np.float32
      r = np.asarray(a, dtype=t)
      if np.isnan(np.sum(r)):
          raise ValueError(
              "Received a time_step input that converted to a nan array."
              " Did you accidentally set some input value to None?.\n"
              "Got:\n{}".format(a)
          )
      return r
  
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 1 for calling a global function with example usage: _as_array(a, t) and returns: r