code: def from_spec(spec):
      """Maps the given spec into corresponding TensorSpecs keeping bounds."""
  
      def _convert_to_tensor_spec(s):
          # Need to check bounded first as non bounded specs are base class.
          if isinstance(s, tf.TypeSpec):
              return s
          if is_bounded(s):
              return BoundedTensorSpec.from_spec(s)
          elif isinstance(s, array_spec.ArraySpec):
              return TensorSpec.from_spec(s)
          else:
              raise ValueError(
                  "No known conversion from type `%s` to a TensorSpec.  Saw:\n  %s"
                  % (type(s), s)
              )
  
      return tf.nest.map_structure(_convert_to_tensor_spec, 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 4 for calling a global function with example usage: from_spec(spec) and returns: tf, s, BoundedTensorSpec, TensorSpec