code: def train(self, corpus):
      assert isinstance(corpus, ParsedCorpus)
      tagged_docs = []
      try:
          import gensim
      except:
          raise Exception(
              "Please install gensim before using Doc2VecCategoryProjector/"
          )
      for doc, tag in zip(
          corpus.get_parsed_docs(), corpus.get_category_names_by_row()
      ):
          words = list(
              itertools.chain(
                  *[
                      [
                          t.lower_
                          for t in sent
                          if not t.is_punct
                          if t.lower_.strip()
                      ]
                      for sent in doc.sents
                  ]
              )
          )
          tagged_docs.append(
              gensim.models.doc2vec.TaggedDocument(words, [tag])
          )
  
      self.model.build_vocab(tagged_docs)
  
      self.cartegory2dvid = {}
      for i in range(corpus.get_num_categories()):
          self.cartegory2dvid[self.model.docvecs.index_to_doctag(i)] = i
  
      self.model.train(
          tagged_docs,
          total_examples=self.model.corpus_count,
          epochs=self.model.epochs,
      )
      self.corpus = corpus
      return self.model
  
imports: import itertools
  from scattertext.ParsedCorpus import ParsedCorpus
label_desc: Use image node_id 2 for calling the Doc2VecBuilder obj's underlying member method code with example usage: obj.train(corpus) and returns: self