code: def get_outer_shape(nested_tensor, spec):
      """Runtime batch dims of tensor's batch dimension `dim`.
  
      Args:
        nested_tensor: Nest of tensors.
        spec: The nested spec.
  
      Returns:
        A `Tensor` containing the outer shape.
  
      Raises:
        ValueError: If `nested_tensor` and `spec` have different structures.
        TypeError: If `nested_tensor` and `spec` structures have differing types.
      """
      assert_same_structure(
          nested_tensor,
          spec,
          message="Tensors and specs do not have matching structures",
      )
      first_tensor = tf.nest.flatten(nested_tensor)[0]
      first_spec = tf.nest.flatten(spec)[0]
  
      # Check tensors have same batch shape.
      num_outer_dims = len(first_tensor.shape) - len(first_spec.shape)
      if not is_batched_nested_tensors(
          nested_tensor,
          spec,
          num_outer_dims=num_outer_dims,
          check_dtypes=False,
      ):
          return tf.constant([], dtype=tf.int32)
  
      return tf.shape(input=first_tensor)[:num_outer_dims]
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import numbers
  from typing import Optional, Text
  from absl import logging
  import numpy
  from six.moves import zip
  import tensorflow
  from tf_agents.typing import types
  from tf_agents.utils import composite
  import wrapt
  from tensorflow.python.util import nest
label_desc: Use image node_id 22 for calling a global function with example usage: get_outer_shape(nested_tensor, spec) and returns: tf, tf