def create_s2s_dataset(
        examples,
        train_mode,
        tokenizer,
        output_dir,
        local_rank=-1,
        cached_features_file=None,
        top_n=-1,
    ):
        """
        Creates S2SAbsSumDataset from input file or list of dictionaries.

        Args:
            examples (str or list): Input file path or list of dictionaries.
                The input file should be in the following format:
                {"src": "abcdefg", "tgt": "ag"}
                {"src": "hijklmn", "tgt": "hn"}
                where the "src" field is the input text to summarize and the "tgt"
                field is the summary.
                The list of dictionaries should be in similar format:
                [{"src": "abcdefg", "tgt": "ag"},
                {"src": "hijklmn", "tgt": "hn"}]
                The "tgt" field is optional if `train_mode` is False.
            train_mode (bool): Whether the input data is for training or testing.
                If True, both "src" and "tgt" fields need to be provided in
                `examples`.
                If False, only the "src" field is required.
            tokenizer (tokenizer): Tokenizer used to convert tokens to token ids. The
                type of the tokenizer depends on the model that will be used.
            output_dir (str): Directory to save the cached features files.
            local_rank (int, optional): Local rank of the device in distributed
                training. Defaults to -1, which means non-distributed training.
            cached_features_file (str, optional): Path of the cached features file.
                If provided and the file already exists, it is loaded and used.
                If provided and the file doesn't exist, processed features are
                saved to this file.
                If not provided, processed features are saved to `output_dir`.
                Defaults to None.
            top_n (int, optional): The number which specifies how many examples in the
                beginning that will be used to create the dataset. Defaults to -1,
                which means the whole lists of examples should be used.

        Returns:
            S2SAbsSumDataset

        """
        if train_mode:
            cached_features_file_name = "cached_features_for_training.pt"
            shuffle_flag = True
        else:
            cached_features_file_name = "cached_features_for_testing.pt"
            shuffle_flag = False

        if not os.path.exists(output_dir):
            os.mkdir(output_dir)

        if cached_features_file is None:
            cached_features_file = os.path.join(output_dir, cached_features_file_name)
            if os.path.exists(cached_features_file):
                os.remove(cached_features_file)
        else:
            if os.path.exists(cached_features_file):
                print("use cached feature file {}".format(cached_features_file))

        features = load_and_cache_examples(
            input_examples=examples,
            tokenizer=tokenizer,
            cached_features_file=cached_features_file,
            shuffle=shuffle_flag,
            local_rank=local_rank,
            train_mode=train_mode,
            top_n=top_n,
        )

        if not train_mode:
            features = [
                tokenizer.convert_ids_to_tokens(line["source_ids"]) for line in features
            ]

            features = sorted(list(enumerate(features)), key=lambda x: -len(x[1]))

        return S2SAbsSumDataset(features)

        Creates S2SAbsSumDataset from input file or list of dictionaries.

        Args:
            examples (str or list): Input file path or list of dictionaries.
                The input file should be in the following format:
                {"src": "abcdefg", "tgt": "ag"}
                {"src": "hijklmn", "tgt": "hn"}
                where the "src" field is the input text to summarize and the "tgt"
                field is the summary.
                The list of dictionaries should be in similar format:
                [{"src": "abcdefg", "tgt": "ag"},
                {"src": "hijklmn", "tgt": "hn"}]
                The "tgt" field is optional if `train_mode` is False.
            train_mode (bool): Whether the input data is for training or testing.
                If True, both "src" and "tgt" fields need to be provided in
                `examples`.
                If False, only the "src" field is required.
            tokenizer (tokenizer): Tokenizer used to convert tokens to token ids. The
                type of the tokenizer depends on the model that will be used.
            output_dir (str): Directory to save the cached features files.
            local_rank (int, optional): Local rank of the device in distributed
                training. Defaults to -1, which means non-distributed training.
            cached_features_file (str, optional): Path of the cached features file.
                If provided and the file already exists, it is loaded and used.
                If provided and the file doesn't exist, processed features are
                saved to this file.
                If not provided, processed features are saved to `output_dir`.
                Defaults to None.
            top_n (int, optional): The number which specifies how many examples in the
                beginning that will be used to create the dataset. Defaults to -1,
                which means the whole lists of examples should be used.

        Returns:
            S2SAbsSumDataset

        
utils_nlp/models/transformers/abstractive_summarization_seq2seq.py