code: def assert_same_structure(
      nest1,
      nest2,
      check_types: bool = True,
      expand_composites: bool = False,
      allow_shallow_nest1: bool = False,
      message: Optional[Text] = None,
  ) -> None:
      """Same as tf.nest.assert_same_structure but with cleaner error messages.
  
      Args:
        nest1: an arbitrarily nested structure.
        nest2: an arbitrarily nested structure.
        check_types: if `True` (default) types of sequences are checked as well,
          including the keys of dictionaries. If set to `False`, for example a list
          and a tuple of objects will look the same if they have the same size. Note
          that namedtuples with identical name and fields are always considered to
          have the same shallow structure. Two types will also be considered the
          same if they are both list subtypes (which allows "list" and
          "_ListWrapper" from trackable dependency tracking to compare equal).
        expand_composites: If true, then composite tensors such as `tf.SparseTensor`
          and `tf.RaggedTensor` are expanded into their component tensors.
        allow_shallow_nest1: If `True`, `nest1` is allowed to be more shallow than
          `nest2`.
        message: Optional error message to provide in case of failure.
  
      Raises:
        ValueError: If the two structures do not have the same number of elements
          or if the two structures are not nested in the same way.
        TypeError: If the two structures differ in the type of sequence in any
          of their substructures. Only possible if `check_types is True`.
      """
      if not isinstance(check_types, bool):
          raise TypeError(
              "check_types must be a bool but saw: '{}'".format(
                  check_types
              )
          )
      if not isinstance(expand_composites, bool):
          raise TypeError(
              "expand_composites must be a bool but saw: '{}'".format(
                  expand_composites
              )
          )
      message = message or "The two structures do not match"
      exception = None
  
      if allow_shallow_nest1:
          check_fn = nest.assert_shallow_structure
      else:
          check_fn = tf.nest.assert_same_structure
  
      try:
          check_fn(
              nest1,
              nest2,
              check_types=check_types,
              expand_composites=expand_composites,
          )
      except (TypeError, ValueError) as e:
          exception = type(e)
  
      if exception:
          str1 = tf.nest.map_structure(
              lambda _: _DOT, nest1, expand_composites=expand_composites
          )
          str2 = tf.nest.map_structure(
              lambda _: _DOT, nest2, expand_composites=expand_composites
          )
          raise exception(
              "{}:\n  {}\nvs.\n  {}\nValues:\n  {}\nvs.\n  {}.".format(
                  message, str1, str2, nest1, nest2
              )
          )
  
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 1 for calling a global function with example usage: assert_same_structure(nest1, nest2, check_types, expand_composites, allow_shallow_nest1, message) without return types