from typing import Dict
from typing import Any
from typing import Union


def get_cluster_mode(
        cycle_config: Dict[str, Any],
) -> Union[None, str]:
    """
    Decode the cluster mode from the cycle configuration. Currently only a
    `slurm`, `local`, or None mode are available.

    Parameters
    ----------
    cycle_config : Dict[str, Any]
        The cluster mode is searched within this cycle configuration.

    Returns
    -------
    mode : str or None
        The specified cluster mode. If the mode is None, then no mode was found.
    """
    try:
        if cycle_config['CLUSTER']['slurm']:
            mode = 'slurm'
        else:
            mode = 'local'
    except KeyError:
        mode = None
    return mode