def predict(self, to_predict):
    '\n        Performs predictions on a list of text.\n\n        Args:\n            to_predict: A python list of text (str) to be sent to the model for prediction. Note that the prefix should be prepended to the text.\n\n        Returns:\n            preds: A python list of the generated sequences.\n        '
    self._move_model_to_device()
    all_outputs = []
    for batch in [to_predict[i:(i + self.args.eval_batch_size)] for i in range(0, len(to_predict), self.args.eval_batch_size)]:
        if (self.args.model_type == 'marian'):
            input_ids = self.encoder_tokenizer.prepare_translation_batch(batch, max_length=self.args.max_seq_length, pad_to_max_length=True, return_tensors='pt')['input_ids']
        else:
            input_ids = self.encoder_tokenizer.batch_encode_plus(batch, max_length=self.args.max_seq_length, pad_to_max_length=True, return_tensors='pt')['input_ids']
        input_ids = input_ids.to(self.device)
        if (self.args.model_type in ['bart', 'marian']):
            outputs = self.model.generate(input_ids=input_ids, num_beams=self.args.num_beams, max_length=self.args.max_length, length_penalty=self.args.length_penalty, early_stopping=self.args.early_stopping, repetition_penalty=self.args.repetition_penalty, do_sample=self.args.do_sample, top_k=self.args.top_k, top_p=self.args.top_p, num_return_sequences=self.args.num_return_sequences)
        else:
            outputs = self.model.generate(input_ids=input_ids, decoder_start_token_id=self.model.config.decoder.pad_token_id, num_beams=self.args.num_beams, max_length=self.args.max_length, length_penalty=self.args.length_penalty, early_stopping=self.args.early_stopping, repetition_penalty=self.args.repetition_penalty, do_sample=self.args.do_sample, top_k=self.args.top_k, top_p=self.args.top_p, num_return_sequences=self.args.num_return_sequences)
        all_outputs.extend(outputs.cpu().numpy())
    if self.args.use_multiprocessed_decoding:
        self.model.to('cpu')
        with Pool(self.args.process_count) as p:
            outputs = list(tqdm(p.imap(self._decode, all_outputs, chunksize=self.args.multiprocessing_chunksize), total=len(all_outputs), desc='Decoding outputs', disable=self.args.silent))
        self._move_model_to_device()
    else:
        outputs = [self.decoder_tokenizer.decode(output_id, skip_special_tokens=True, clean_up_tokenization_spaces=True) for output_id in all_outputs]
    if (self.args.num_return_sequences > 1):
        return [outputs[i:(i + self.args.num_return_sequences)] for i in range(0, len(outputs), self.args.num_return_sequences)]
    else:
        return outputs
Performs predictions on a list of text.

Args:
    to_predict: A python list of text (str) to be sent to the model for prediction. Note that the prefix should be prepended to the text.

Returns:
    preds: A python list of the generated sequences.
def predict(self, to_predict):
    '\n        Performs predictions on a list of text.\n\n        Args:\n            to_predict: A python list of text (str) to be sent to the model for prediction. Note that the prefix should be prepended to the text.\n\n        Returns:\n            preds: A python list of the generated sequences.\n        '
    self._move_model_to_device()
    all_outputs = []
    for batch in [to_predict[i:(i + self.args.eval_batch_size)] for i in range(0, len(to_predict), self.args.eval_batch_size)]:
        if (self.args.model_type == 'marian'):
            input_ids = self.encoder_tokenizer.prepare_translation_batch(batch, max_length=self.args.max_seq_length, pad_to_max_length=True, return_tensors='pt')['input_ids']
        else:
            input_ids = self.encoder_tokenizer.batch_encode_plus(batch, max_length=self.args.max_seq_length, pad_to_max_length=True, return_tensors='pt')['input_ids']
        input_ids = input_ids.to(self.device)
        if (self.args.model_type in ['bart', 'marian']):
            outputs = self.model.generate(input_ids=input_ids, num_beams=self.args.num_beams, max_length=self.args.max_length, length_penalty=self.args.length_penalty, early_stopping=self.args.early_stopping, repetition_penalty=self.args.repetition_penalty, do_sample=self.args.do_sample, top_k=self.args.top_k, top_p=self.args.top_p, num_return_sequences=self.args.num_return_sequences)
        else:
            outputs = self.model.generate(input_ids=input_ids, decoder_start_token_id=self.model.config.decoder.pad_token_id, num_beams=self.args.num_beams, max_length=self.args.max_length, length_penalty=self.args.length_penalty, early_stopping=self.args.early_stopping, repetition_penalty=self.args.repetition_penalty, do_sample=self.args.do_sample, top_k=self.args.top_k, top_p=self.args.top_p, num_return_sequences=self.args.num_return_sequences)
        all_outputs.extend(outputs.cpu().numpy())
    if self.args.use_multiprocessed_decoding:
        self.model.to('cpu')
        with Pool(self.args.process_count) as p:
            outputs = list(tqdm(p.imap(self._decode, all_outputs, chunksize=self.args.multiprocessing_chunksize), total=len(all_outputs), desc='Decoding outputs', disable=self.args.silent))
        self._move_model_to_device()
    else:
        outputs = [self.decoder_tokenizer.decode(output_id, skip_special_tokens=True, clean_up_tokenization_spaces=True) for output_id in all_outputs]
    if (self.args.num_return_sequences > 1):
        return [outputs[i:(i + self.args.num_return_sequences)] for i in range(0, len(outputs), self.args.num_return_sequences)]
    else:
        return outputs