<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def determine_scheduler( scheduler: Optional[str], experiment_definition: Dict[str, YamlValue] ) -> str: """Determine the scheduler to use to run the jobs."""


    # Scheduler value from command line has first priority
    if scheduler is not None:
        if scheduler in ["shell", "pbs", "slurm"]:
            return scheduler
        raise ValueError(
            "Argument scheduler only supports input values of ['shell', 'pbs', 'slurm']"
        )

    # Next priority goes to the experiment.yml file
    if experiment_definition.get("pbs"):
        return "pbs"
    if experiment_definition.get("slurm"):
        return "slurm"
    if experiment_definition.get("shell"):
        return "shell"

    # Final priority goes to the auto-discovery
    if shutil.which("pbs") is not None:
        return "pbs"
    if shutil.which("slurm") is not None:
        return "slurm"

    # Default if nothing else is found goes to shell
    return "shell"