def _infer_modality_based_on_extension(extension: str) -> Optional[Modality]:
    """
    Infer the modality based on the file extension. Is it is not a known extension, return None.

    Args:
        extension: A string representing the file extension (e.g., 'jpg', 'mp4', etc.)

    Returns:
        Modality: The inferred modality (IMAGE, VIDEO, AUDIO, or None if unknown)
    """
    if not extension or not isinstance(extension, str):
        return None

    extension = extension.lower()

    if extension in ['jpg', 'jpeg', 'png', 'gif', 'webp']:
        return Modality.IMAGE
    elif extension in ['mp4', 'avi', 'mov']:
        return Modality.VIDEO
    elif extension in ['mp3', 'wav', 'ogg']:
        return Modality.AUDIO
    else:
        return None

    Infer the modality based on the file extension. Is it is not a known extension, return None.

    Args:
        extension: A string representing the file extension (e.g., 'jpg', 'mp4', etc.)

    Returns:
        Modality: The inferred modality (IMAGE, VIDEO, AUDIO, or None if unknown)
    
src/marqo/core/inference/modality_utils.py