from typing import Optional


def get_number_of_atoms(coords: Optional[dict]) -> Optional[int]:
    """
    Get the number of atoms in a coordinates dictionary.
    Has many safety checks to be safely used in the schema.

    Args:
        coords (dict): The coordinates dictionary.

    Returns:
        Optional[int]: The number of atoms in the coordinates matrix.
    """
    if coords is not None:
        if 'coordinates' in coords:
            coords = coords['coordinates']
        if isinstance(coords, dict) and 'symbols' in coords and isinstance(coords['symbols'], (list, tuple)):
            return len(coords['symbols'])
    return None