from typing import Optional


def get_scheduler_state(code: int) -> Optional[str]:
    """Translate an schduler state code to a human-readable state.

    Official mapping is available
    `here <https://github.com/BOINC/boinc/blob/master/py/Boinc/boinc_db.py>`.

    Args:
      code:
        The code of scheduler state.

    Returns:
      The human-readable state related to the code.
    """

    states = {
        0: "UNINITIALIZED",
        1: "PREEMPTED",
        2: "SCHEDULED",
    }
    return states.get(int(code))