code: def assert_shallow_structure(
      modality,
      shallow_tree,
      input_tree,
      check_types=True,
      expand_composites=False,
  ):
      """Asserts that `shallow_tree` is a shallow structure of `input_tree`.
  
      This function tests if the `input_tree` structure can be created from
      the `shallow_tree` structure by replacing its leaf nodes with deeper
      tree structures.
  
      Examples:
  
      The following code will raise an exception:
      ```python
        shallow_tree = {"a": "A", "b": "B"}
        input_tree = {"a": 1, "c": 2}
        assert_shallow_structure(shallow_tree, input_tree)
      ```
  
      The following code will raise an exception:
      ```python
        shallow_tree = ["a", "b"]
        input_tree = ["c", ["d", "e"], "f"]
        assert_shallow_structure(shallow_tree, input_tree)
      ```
  
      Args:
        modality: enum value of supported modality [Modality.CORE or Modality.DATA]
        shallow_tree: an arbitrarily nested structure.
        input_tree: an arbitrarily nested structure.
        check_types: if `True` (default) the sequence types of `shallow_tree` and
          `input_tree` have to be the same. Note that even with check_types==True,
          this function will consider two different namedtuple classes with the same
          name and _fields attribute to be the same class.
        expand_composites: Valid for Modality.CORE only. If true, then composite
          tensors such as `tf.sparse.SparseTensor` and `tf.RaggedTensor` are
          expanded into their component tensors.
  
      Raises:
        TypeError: If `shallow_tree` is a sequence but `input_tree` is not.
        TypeError: If the sequence types of `shallow_tree` are different from
          `input_tree`. Only raised if `check_types` is `True`.
        ValueError: If the sequence lengths of `shallow_tree` are different from
          `input_tree`.
      """
      if modality == Modality.CORE:
          _tf_core_assert_shallow_structure(
              shallow_tree, input_tree, check_types, expand_composites
          )
      elif modality == Modality.DATA:
          _tf_data_assert_shallow_structure(
              shallow_tree, input_tree, check_types
          )
      else:
          raise ValueError(
              "Unknown modality used {} for nested structure".format(
                  modality
              )
          )
  
imports: import collections
  import enum
  import wrapt
  from tensorflow.python import pywrap_tensorflow
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.util import _pywrap_utils
  from tensorflow.python.util.compat import collections_abc
  from tensorflow.python.util.custom_nest_protocol import CustomNestProtocol
label_desc: Use image node_id 28 for calling a global function with example usage: assert_shallow_structure(modality, shallow_tree, input_tree, check_types, expand_composites) without return types