docstr: Perform LDA topic inference on input, and store the results in doc.
  Args:
      input: a list of strings after tokenization.
      doc: LDADoc type or SLDADoc type.
docstr_tok: ["Perform","LDA","topic","inference","on","input",",","and","store","the","results","in","doc",".","Args",":","input",":","a","list","of","strings","after","tokenization",".","doc",":","LDADoc","type","or","SLDADoc","type","."]
code: def infer(self, input, doc):
      """Perform LDA topic inference on input, and store the results in doc.
      Args:
          input: a list of strings after tokenization.
          doc: LDADoc type or SLDADoc type.
      """
      fix_random_seed()
      if isinstance(doc, LDADoc) and not isinstance(doc, SLDADoc):
          doc.init(self.__model.num_topics())
          doc.set_alpha(self.__model.alpha())
          for token in input:
              id_ = self.__model.term_id(token)
              if id_ != OOV:
                  init_topic = rand_k(self.__model.num_topics())
                  doc.add_token(Token(init_topic, id_))
          self.lda_infer(doc, 20, 50)
      elif isinstance(doc, SLDADoc):
          doc.init(self.__model.num_topics())
          doc.set_alpha(self.__model.alpha())
          for sent in input:
              words = []
              for token in sent:
                  id_ = self.__model.term_id(token)
                  if id_ != OOV:
                      words.append(id_)
              init_topic = rand_k(self.__model.num_topics())
              doc.add_sentence(Sentence(init_topic, words))
          self.slda_infer(doc, 20, 50)
      else:
          logger.error("Wrong Doc Type!")
  
file_path: PaddleHub/modules/text/language_model/slda_news/inference_engine.py
imports: import os
  from paddlehub.common.logger import logger
  from slda_news.config import ModelConfig
  from slda_news.util import load_prototxt, fix_random_seed, rand_k
  from slda_news.model import TopicModel
  from slda_news.sampler import GibbsSampler, MHSampler
  from slda_news.document import LDADoc, SLDADoc, Token, Sentence
  from slda_news.vocab import OOV
label_desc: Use image node_id 2 for calling the InferenceEngine obj's underlying member method code with example usage: obj.infer(input, doc) without return types