def get_labels_and_texts(self, metadata=None):
        '''
        Parameters
        ----------
        metadata : (array like or None)

        Returns
        -------
        {'labels':[], 'texts': []} or {'labels':[], 'texts': [], 'meta': []}
        '''
        to_ret = {'categories': self._corpus.get_categories(), 'labels': [], 'texts': []}
        labels = self._corpus._y.astype(int)
        texts = self._get_texts_to_display()
        if self._use_non_text_features:
            to_ret['extra'] = []
            extrafeats = self._corpus.list_extra_features()
        if metadata is not None:
            to_ret['meta'] = []
        for label_i in range(len(self._corpus._category_idx_store)):
            label_indices = np.arange(0, len(labels))[labels == label_i]
            if self.max_per_category < len(label_indices):
                label_indices = np.random.choice(label_indices, self.max_per_category, replace=False)
                to_ret['labels'] += list([int(e) for e in labels[label_indices]])
                to_ret['texts'] += list(texts[label_indices])
                if metadata is not None:
                    to_ret['meta'] += [metadata[i] for i in label_indices]
                if self._use_non_text_features:
                    to_ret['extra'] += [extrafeats[i] for i in label_indices]

        return to_ret

        Parameters
        ----------
        metadata : (array like or None)

        Returns
        -------
        {'labels':[], 'texts': []} or {'labels':[], 'texts': [], 'meta': []}
        
scattertext/DocsAndLabelsFromCorpus.py