def use_categories_as_metadata_and_replace_terms(self):
        '''
        Returns a TermDocMatrix which is identical to self except the metadata values are now identical to the
         categories present and term-doc-matrix is now the metadata matrix.

        :return: TermDocMatrix
        '''
        new_tdm = self._make_new_term_doc_matrix(
            new_X=self._mX,
            new_mX=self._categories_to_metadata_factory(),
            new_y=self._y,
            new_term_idx_store=self._metadata_idx_store,
            new_category_idx_store=self._category_idx_store,
            new_metadata_idx_store=copy(self._category_idx_store),
            new_y_mask=self._y == self._y,
            new_term_offsets=self._metadata_offsets,
            new_metadata_offsets={k: [] for k in self.get_categories()},
        )
        return new_tdm

        Returns a TermDocMatrix which is identical to self except the metadata values are now identical to the
         categories present and term-doc-matrix is now the metadata matrix.

        :return: TermDocMatrix
        
scattertext/OffsetCorpus.py