code: def _convert_to_spec_and_remove_singleton_batch_dim(
      parameters: distribution_utils.Params, outer_ndim: int
  ) -> distribution_utils.Params:
      """Convert a `Params` object of tensors to one containing unbatched specs.
  
      Note: The `Params` provided to this function are typically contain tensors
      generated by Layers and therefore containing an outer singleton dimension.
  
      Since TF-Agents specs exclude batch and time prefixes, here we need to
      remove the singleton batch dimension from the specs created by these
      input tensors.
  
      Args:
        parameters: Distribution parameters, including input tensors.
        outer_ndim: Number of singleton outer dimensions expected in tensors found
          in `parameters`.
  
      Returns:
        A `Params` object contanining `tf.TypeSpec` in place of tensors, with
        up to `outer_ndim` outer singleton dimensions removed.
      """
  
      def _maybe_convert_to_spec(p):
          if isinstance(p, distribution_utils.Params):
              return _convert_to_spec_and_remove_singleton_batch_dim(
                  p, outer_ndim
              )
          elif tf.is_tensor(p):
              return tensor_spec.remove_outer_dims_nest(
                  tf.type_spec_from_value(p), num_outer_dims=outer_ndim
              )
          else:
              return p
  
      return distribution_utils.Params(
          type_=parameters.type_,
          params=tf.nest.map_structure(
              _maybe_convert_to_spec, parameters.params
          ),
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import abc
  import typing
  import six
  import tensorflow
  import tensorflow_probability
  from tf_agents.distributions import utils
  from tf_agents.networks import layer_utils
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import time_step
  from tf_agents.typing import types
  from tf_agents.utils import common
  from tf_agents.utils import nest_utils
  from tf_agents.utils import object_identity
  from tensorflow.python.trackable import base
  from tensorflow.python.util import tf_decorator
  from tensorflow.python.util import tf_inspect
label_desc: Use image node_id 3 for calling a global function with example usage: _convert_to_spec_and_remove_singleton_batch_dim(parameters, outer_ndim) and returns: distribution_utils, _convert_to_spec_and_remove_singleton_batch_dim, tensor_spec, p