code: def __doc_proposal(self, doc, token):
      if isinstance(doc, LDADoc) and isinstance(token, Token):
          old_topic = token.topic
          dart = rand() * (doc.size() + self.__model.alpha_sum())
          if dart < doc.size():
              token_index = int(dart)
              new_topic = doc.token(token_index).topic
          else:
              new_topic = rand_k(self.__model.num_topics())
  
          if new_topic != old_topic:
              proposal_old = self.__doc_proposal_distribution(
                  doc, old_topic
              )
              proposal_new = self.__doc_proposal_distribution(
                  doc, new_topic
              )
              proportion_old = self.__proportional_function(
                  doc, token, old_topic
              )
              proportion_new = self.__proportional_function(
                  doc, token, new_topic
              )
              transition_prob = float(
                  (proportion_new * proposal_old)
                  / (proportion_old * proposal_new)
              )
              rejection = rand()
              mask = -(rejection < transition_prob)
              return (new_topic & mask) | (old_topic & ~mask)
  
          return new_topic
  
      elif isinstance(doc, SLDADoc) and isinstance(token, Sentence):
          sent = token
          old_topic = sent.topic
          dart = rand() * (doc.size() + self.__model.alpha_sum())
          if dart < doc.size():
              token_index = int(dart)
              new_topic = doc.sent(token_index).topic
          else:
              new_topic = rand_k(self.__model.num_topics())
  
          if new_topic != old_topic:
              proportion_old = self.__proportional_function(
                  doc, sent, old_topic
              )
              proportion_new = self.__proportional_function(
                  doc, sent, new_topic
              )
              proposal_old = self.__doc_proposal_distribution(
                  doc, old_topic
              )
              proposal_new = self.__doc_proposal_distribution(
                  doc, new_topic
              )
              transition_prob = float(
                  (proportion_new * proposal_old)
                  / (proportion_old * proposal_new)
              )
              rejection = rand()
              mask = -(rejection < transition_prob)
              return (new_topic & mask) | (old_topic & ~mask)
  
          return new_topic
  
imports: import os
  import numpy
  from tqdm import tqdm
  from paddlehub.common.logger import logger
  from lda_novel.document import LDADoc, SLDADoc, Token, Sentence
  from lda_novel.vose_alias import VoseAlias
  from lda_novel.util import rand, rand_k
label_desc: Use image node_id 6 for calling the MHSampler obj's underlying member method code with example usage: obj.__doc_proposal(doc, token) and returns: new_topic, unknown, new_topic, unknown