def assert_same(nest1, nest2):
  """Assert that both structures are equivalent.

  This function is more strict than tf.nest.assert_same_structure since it also
  requires that Tensors have the same dtype and shape.

  Args:
    nest1: A nested structure.
    nest2: A nested structure.
  """
  tf.nest.assert_same_structure(nest1, nest2)
  for t1, t2 in zip(tf.nest.flatten(nest1), tf.nest.flatten(nest2)):
    assert t1.dtype == t2.dtype
    if isinstance(t1, tf.Tensor) and isinstance(t2, tf.Tensor):
      assert t1.shape == t2.shape
Assert that both structures are equivalent.

  This function is more strict than tf.nest.assert_same_structure since it also
  requires that Tensors have the same dtype and shape.

  Args:
    nest1: A nested structure.
    nest2: A nested structure.
  
language/common/utils/nest_utils.py