code: def construct_author2doc(doc2author):
      """Make a mapping from author IDs to document IDs.
  
      Parameters
      ----------
      doc2author: dict of (int, list of str)
          Mapping of document id to authors.
  
      Returns
      -------
      dict of (str, list of int)
          Mapping of authors to document ids.
  
      """
      # First get a set of all authors.
      authors_ids = set()
      for d, a_doc_ids in doc2author.items():
          for a in a_doc_ids:
              authors_ids.add(a)
  
      # Now construct the dictionary.
      author2doc = {}
      for a in authors_ids:
          author2doc[a] = []
          for d, a_ids in doc2author.items():
              if a in a_ids:
                  author2doc[a].append(d)
      return author2doc
  
imports: import logging
  from itertools import chain
  from copy import deepcopy
  from shutil import copyfile
  from os.path import isfile
  from os import remove
  import numpy
  from scipy.special import gammaln
  from gensim import utils
  from gensim.models import LdaModel
  from gensim.models.ldamodel import LdaState
  from gensim.matutils import dirichlet_expectation, mean_absolute_difference
  from gensim.corpora import MmCorpus
label_desc: Use image node_id 2 for calling a global function with example usage: construct_author2doc(doc2author) and returns: author2doc