code: def _topic_info(
      topic_term_dists,
      topic_proportion,
      term_frequency,
      term_topic_freq,
      vocab,
      lambda_step,
      R,
      n_jobs,
      start_index=1,
  ):
      # marginal distribution over terms (width of blue bars)
      term_proportion = term_frequency / term_frequency.sum()
  
      # compute the distinctiveness and saliency of the terms:
      # this determines the R terms that are displayed when no topic is selected.
      # TODO(msusol): Make flake8 test pass here with 'unused' variables.
      tt_sum = topic_term_dists.sum()
      topic_given_term = pd.eval("topic_term_dists / tt_sum")
      log_1 = np.log(pd.eval("topic_given_term.T / topic_proportion"))
      kernel = pd.eval("topic_given_term * log_1.T")
      distinctiveness = kernel.sum()
      saliency = term_proportion * distinctiveness
      # Order the terms for the "default" view by decreasing saliency:
      default_term_info = pd.DataFrame(
          {
              "saliency": saliency,
              "Term": vocab,
              "Freq": term_frequency,
              "Total": term_frequency,
              "Category": "Default",
          }
      )
      default_term_info = (
          default_term_info.sort_values(by="saliency", ascending=False)
          .head(R)
          .drop("saliency", axis=1)
      )
      # Rounding Freq and Total to integer values to match LDAvis code:
      default_term_info["Freq"] = np.floor(default_term_info["Freq"])
      default_term_info["Total"] = np.floor(default_term_info["Total"])
      ranks = np.arange(R, 0, -1)
      default_term_info["logprob"] = default_term_info[
          "loglift"
      ] = ranks
      default_term_info = default_term_info.reindex(
          columns=[
              "Term",
              "Freq",
              "Total",
              "Category",
              "logprob",
              "loglift",
          ]
      )
  
      # compute relevance and top terms for each topic
      log_lift = np.log(
          pd.eval("topic_term_dists / term_proportion")
      ).astype("float64")
      log_ttd = np.log(pd.eval("topic_term_dists")).astype("float64")
      lambda_seq = np.arange(0, 1 + lambda_step, lambda_step)
  
      def topic_top_term_df(tup):
          new_topic_id, (original_topic_id, topic_terms) = tup
          term_ix = topic_terms.unique()
          df = pd.DataFrame(
              {
                  "Term": vocab[term_ix],
                  "Freq": term_topic_freq.loc[
                      original_topic_id, term_ix
                  ],
                  "Total": term_frequency[term_ix],
                  "Category": "Topic%d" % new_topic_id,
                  "logprob": log_ttd.loc[
                      original_topic_id, term_ix
                  ].round(4),
                  "loglift": log_lift.loc[
                      original_topic_id, term_ix
                  ].round(4),
              }
          )
          return df.reindex(
              columns=[
                  "Term",
                  "Freq",
                  "Total",
                  "Category",
                  "logprob",
                  "loglift",
              ]
          )
  
      top_terms = pd.concat(
          Parallel(n_jobs=n_jobs)(
              delayed(_find_relevance_chunks)(log_ttd, log_lift, R, ls)
              for ls in _job_chunks(lambda_seq, n_jobs)
          )
      )
      topic_dfs = map(
          topic_top_term_df,
          enumerate(top_terms.T.iterrows(), start_index),
      )
      return pd.concat([default_term_info] + list(topic_dfs))
  
imports: import json
  import logging
  import numpy
  import pandas
  from collections import namedtuple
  from joblib import Parallel, delayed, cpu_count
  from scipy.stats import entropy
  from scipy.spatial.distance import pdist, squareform
  from sklearn.manifold import MDS, TSNE
  from pyLDAvis.utils import NumPyEncoder
label_desc: Use image node_id 16 for calling a global function with example usage: _topic_info(topic_term_dists, topic_proportion, term_frequency, term_topic_freq, vocab, lambda_step, R, n_jobs, start_index) and returns: pd, df