src/transformers/pipelines/__init__.py/check_task
def check_task(task: str) -> Tuple[Dict, Any]:
    """
    Checks an incoming task string, to validate it's correct and return the default Pipeline and Model classes, and
    default models if they exist.

    Args:
        task (:obj:`str`):
            The task defining which pipeline will be returned. Currently accepted tasks are:

            - :obj:`"audio-classification"`
            - :obj:`"automatic-speech-recognition"`
            - :obj:`"conversational"`
            - :obj:`"feature-extraction"`
            - :obj:`"fill-mask"`
            - :obj:`"image-classification"`
            - :obj:`"question-answering"`
            - :obj:`"table-question-answering"`
            - :obj:`"text2text-generation"`
            - :obj:`"text-classification"` (alias :obj:`"sentiment-analysis" available)
            - :obj:`"text-generation"`
            - :obj:`"token-classification"` (alias :obj:`"ner"` available)
            - :obj:`"translation"`
            - :obj:`"translation_xx_to_yy"`
            - :obj:`"summarization"`
            - :obj:`"zero-shot-classification"`

    Returns:
        (task_defaults:obj:`dict`, task_options: (:obj:`tuple`, None)) The actual dictionary required to initialize the
        pipeline and some extra task options for parametrized tasks like "translation_XX_to_YY"


    """
    if task in TASK_ALIASES:
        task = TASK_ALIASES[task]
    if task in SUPPORTED_TASKS:
        targeted_task = SUPPORTED_TASKS[task]
        return targeted_task, None

    if task.startswith("translation"):
        tokens = task.split("_")
        if len(tokens) == 4 and tokens[0] == "translation" and tokens[2] == "to":
            targeted_task = SUPPORTED_TASKS["translation"]
            return targeted_task, (tokens[1], tokens[3])
        raise KeyError(f"Invalid translation task {task}, use 'translation_XX_to_YY' format")

    raise KeyError(
        f"Unknown task {task}, available tasks are {list(SUPPORTED_TASKS.keys()) + ['translation_XX_to_YY']}"
    )