def collate(self, data, block_size, device, train_mode=True):
        """ Collcate function for pytorch data loaders.
            Args:
                data (list): A list of samples from SummarizationDataset.
                block_size (int): maximum input length for the model.
                train_mode (bool): whether the collate function is used for training
                    or not. Defaults to True.

            Returns:
                `Batch` object: a data minibatch as the input of a model.

        """

        if len(data) == 0:
            return None
        else:
            if train_mode is True and "tgt" in data[0] and "oracle_ids" in data[0]:
                encoded_text = [self.encode_single(d, block_size) for d in data]
                batch = Batch(list(filter(None, encoded_text)), True)
            else:
                encoded_text = [
                    self.encode_single(d, block_size, train_mode) for d in data
                ]
                # src, labels, segs, clss, src_txt, tgt_txt =  zip(*encoded_text)
                # new_data = [list(i) for i in list(zip(*encoded_text))]
                # batch =  Batch(new_data)
                filtered_list = list(filter(None, encoded_text))
                # if len(filtered_list) != len(data):
                #    raise ValueError("no test data shouldn't be skipped")
                batch = Batch(filtered_list)
            return batch.to(device)
 Collcate function for pytorch data loaders.
            Args:
                data (list): A list of samples from SummarizationDataset.
                block_size (int): maximum input length for the model.
                train_mode (bool): whether the collate function is used for training
                    or not. Defaults to True.

            Returns:
                `Batch` object: a data minibatch as the input of a model.

        
utils_nlp/models/transformers/extractive_summarization.py