def get_minibatch(self, sentences, tokenize=False, add_start_end=True):
        """Prepare minibatch.

        Args:
            sentences(list): Sentences to get embeddings.
            tokenize(bool): To tokenize or not.
            add_start_end(bool): To add start and end notation (<s> </s>) to each
            sentence or not.

        Returns:
            dict: A dictionary with sentences, lengths and sentence embeddings.

        """
        if tokenize:
            sentences = [
                nltk.word_tokenize(sentence) for sentence in sentences
            ]
        else:
            sentences = [sentence.split() for sentence in sentences]

        if add_start_end:
            sentences = [
                ["<s>"] + sentence + ["</s>"] for sentence in sentences
            ]

        lens = [len(sentence) for sentence in sentences]
        sorted_idx = np.argsort(lens)[::-1]
        sorted_sentences = [sentences[idx] for idx in sorted_idx]
        rev = np.argsort(sorted_idx)
        sorted_lens = [len(sentence) for sentence in sorted_sentences]
        max_len = max(sorted_lens)

        sentences = [
            [
                self.task_word2id[w]
                if w in self.task_word2id
                else self.task_word2id["<unk>"]
                for w in sentence
            ]
            + [self.task_word2id["<pad>"]] * (max_len - len(sentence))
            for sentence in sorted_sentences
        ]

        with torch.no_grad():
            sentences = Variable(torch.LongTensor(sentences))
            rev = Variable(torch.LongTensor(rev))
        lengths = sorted_lens

        if self.cuda:
            sentences = sentences.cuda()
            rev = rev.cuda()

        return {"sentences": sentences, "lengths": lengths, "rev": rev}
Prepare minibatch.

        Args:
            sentences(list): Sentences to get embeddings.
            tokenize(bool): To tokenize or not.
            add_start_end(bool): To add start and end notation (<s> </s>) to each
            sentence or not.

        Returns:
            dict: A dictionary with sentences, lengths and sentence embeddings.

        
utils_nlp/models/gensen/gensen.py