def shapes(x):
  """Get a structure of shapes for a structure of nested arrays."""
  def shape(x):
    try:
      return x.shape
    except Exception:  # pylint: disable=broad-except
      return []
  return nested_map(x, shape)
Get a structure of shapes for a structure of nested arrays.