def file_tag_from_task_file(file: str, cut_num_injs: bool = False) -> str:
    """Returns the file tag from a task output filename.

    Args:
        file: Filename of task file with or without path.
        cut_num_injs: Whether to not include the number of injections per redshift bin.
    """
    file_tag = file.replace("_TASK_", "results_").split("results_")[1]
    if cut_num_injs:
        return file_tag.split("_INJS-PER-ZBIN_")[0]
    else:
        return file_tag