from typing import Tuple
from typing import Optional
from typing import Dict


def _split_compat_top_bottom(page_info) -> Tuple[Optional[str], Dict[str, str]]:
  """Split the compatibility dict between the top and bottom sections."""
  compat: Dict[str, str] = page_info.doc.compatibility
  top_compat = None

  if ('compat.v1' in page_info.full_name or 'estimator' in page_info.full_name):
    bottom_compat = {}
    for key, value in compat.items():
      if key == 'TF2':
        top_compat = value
      else:
        bottom_compat[key] = value
  else:
    bottom_compat = compat

  return top_compat, bottom_compat