code: def to_array_spec(
      tensor_spec: Union[types.NestedArraySpec, types.NestedTensorSpec]
  ) -> types.NestedArraySpec:
      """Converts TensorSpec into ArraySpec."""
  
      def _convert(s):
          if isinstance(s, array_spec.ArraySpec):
              return s
  
          if hasattr(s, "minimum") and hasattr(s, "maximum"):
              return array_spec.BoundedArraySpec(
                  s.shape.as_list(),
                  s.dtype.as_numpy_dtype,
                  minimum=s.minimum,
                  maximum=s.maximum,
                  name=s.name,
              )
          else:
              return array_spec.ArraySpec(
                  s.shape.as_list(), s.dtype.as_numpy_dtype, s.name
              )
  
      return tf.nest.map_structure(_convert, tensor_spec)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  from typing import Union
  import numpy
  import tensorflow
  import tensorflow_probability
  from tf_agents.specs import array_spec
  from tf_agents.typing import types
  from google.protobuf import text_format
  from tensorflow.core.protobuf import struct_pb2
  from tensorflow.python.framework import tensor_spec
  from tensorflow.python.saved_model import nested_structure_coder
label_desc: Use image node_id 5 for calling a global function with example usage: to_array_spec(tensor_spec) and returns: tf, s, array_spec, array_spec