code: def flatten_and_check_shape_nested_specs(specs, reference_specs):
      """Flatten nested specs and check their shape for use in other functions."""
      try:
          (
              flat_specs,
              flat_shapes,
          ) = _flatten_and_check_shape_nested_tensors(
              specs, reference_specs, num_outer_dims=0
          )
      except ValueError as exc:
          raise ValueError(
              "specs must be compatible with reference_specs"
              "; instead got specs=%s, reference_specs=%s"
              % (specs, reference_specs)
          ) from exc
      return flat_specs, flat_shapes
  
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 16 for calling a global function with example usage: flatten_and_check_shape_nested_specs(specs, reference_specs) and returns: flat_specs,  flat_shapes