parameters: (nest1, nest2, check_types=True)
docstring: Asserts that two structures are nested in the same way.
  
    Args:
      nest1: an arbitrarily nested structure.
      nest2: an arbitrarily nested structure.
      check_types: if `True` (default) types of sequences are checked as
        well. If set to `False`, for example a list and a tuple of objects will
        look same if they have the same size.
  
    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`.
docstring_summary: Asserts that two structures are nested in the same way.
docstring_tokens: Asserts that two structures are nested in the same way .
function: def assert_same_structure(nest1, nest2, check_types=True):
    """Asserts that two structures are nested in the same way.
  
    Args:
      nest1: an arbitrarily nested structure.
      nest2: an arbitrarily nested structure.
      check_types: if `True` (default) types of sequences are checked as
        well. If set to `False`, for example a list and a tuple of objects will
        look same if they have the same size.
  
    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`.
    """
    len_nest1 = len(flatten(nest1)) if is_sequence(nest1) else 1
    len_nest2 = len(flatten(nest2)) if is_sequence(nest2) else 1
    if len_nest1 != len_nest2:
      raise ValueError("The two structures don't have the same number of "
                       "elements. First structure: %s, second structure: %s."
                       % (nest1, nest2))
    _recursive_assert_same_structure(nest1, nest2, check_types)
function_tokens: def assert_same_structure ( nest1 , nest2 , check_types = True ) : len_nest1 = len ( flatten ( nest1 ) ) if is_sequence ( nest1 ) else 1 len_nest2 = len ( flatten ( nest2 ) ) if is_sequence ( nest2 ) else 1 if len_nest1 != len_nest2 : raise ValueError ( "The two structures don't have the same number of " "elements. First structure: %s, second structure: %s." % ( nest1 , nest2 ) ) _recursive_assert_same_structure ( nest1 , nest2 , check_types )