from typing import Optional
from pathlib import Path


def relative_example_path(example_id: str, data_name: Optional[str] = None):
    """
    Returns the relative path from a train or test directory to the data file for the
    given example_id and data_name.
    """
    prefix = data_name + "_" if data_name else ""
    return (
        Path(example_id[0])
        / example_id[1]
        / example_id[2]
        / (prefix + example_id + ".npy")
    )