code: def parametrized_guide(predictor, data, args, batch_size=None):
      # Use a conjugate guide for global variables.
      topic_weights_posterior = pyro.param(
          "topic_weights_posterior",
          lambda: torch.ones(args.num_topics),
          constraint=constraints.positive,
      )
      topic_words_posterior = pyro.param(
          "topic_words_posterior",
          lambda: torch.ones(args.num_topics, args.num_words),
          constraint=constraints.greater_than(0.5),
      )
      with pyro.plate("topics", args.num_topics):
          pyro.sample(
              "topic_weights", dist.Gamma(topic_weights_posterior, 1.0)
          )
          pyro.sample(
              "topic_words", dist.Dirichlet(topic_words_posterior)
          )
  
      # Use an amortized guide for local variables.
      pyro.module("predictor", predictor)
      with pyro.plate("documents", args.num_docs, batch_size) as ind:
          data = data[:, ind]
          # The neural network will operate on histograms rather than word
          # index vectors, so we'll convert the raw data to a histogram.
          counts = torch.zeros(args.num_words, ind.size(0)).scatter_add(
              0, data, torch.ones(data.shape)
          )
          doc_topics = predictor(counts.transpose(0, 1))
          pyro.sample("doc_topics", dist.Delta(doc_topics, event_dim=1))
  
file_path: pyro/examples/lda.py
imports: import argparse
  import functools
  import logging
  import torch
  from torch import nn
  from torch.distributions import constraints
  import pyro
  import pyro.distributions
  from pyro.infer import SVI, JitTraceEnum_ELBO, TraceEnum_ELBO
  from pyro.optim import ClippedAdam
label_desc: Use image node_id 3 for calling a global function with example usage: parametrized_guide(predictor, data, args, batch_size) without return types