code: def reparameterized_discrete_model(args, data):
      # Sample global parameters.
      rate_s, prob_i, rho = global_model(args.population)
  
      # Sequentially sample time-local variables.
      S_curr = torch.tensor(args.population - 1.0)
      I_curr = torch.tensor(1.0)
      for t, datum in enumerate(data):
          # Sample reparameterizing variables.
          # When reparameterizing to a factor graph, we ignored density via
          # .mask(False). Thus distributions are used only for initialization.
          S_prev, I_prev = S_curr, I_curr
          S_curr = pyro.sample(
              "S_{}".format(t),
              dist.Binomial(args.population, 0.5).mask(False),
          )
          I_curr = pyro.sample(
              "I_{}".format(t),
              dist.Binomial(args.population, 0.5).mask(False),
          )
  
          # Now we reverse the computation.
          S2I = S_prev - S_curr
          I2R = I_prev - I_curr + S2I
          pyro.sample(
              "S2I_{}".format(t),
              dist.ExtendedBinomial(S_prev, -(rate_s * I_prev).expm1()),
              obs=S2I,
          )
          pyro.sample(
              "I2R_{}".format(t),
              dist.ExtendedBinomial(I_prev, prob_i),
              obs=I2R,
          )
          pyro.sample(
              "obs_{}".format(t),
              dist.ExtendedBinomial(S2I, rho),
              obs=datum,
          )
  
imports: import argparse
  import logging
  import math
  import re
  from collections import OrderedDict
  import torch
  import pyro
  import pyro.distributions
  import pyro.distributions.hmm
  import pyro.poutine
  from pyro.infer import MCMC, NUTS, config_enumerate, infer_discrete
  from pyro.infer.autoguide import init_to_value
  from pyro.ops.special import safe_log
  from pyro.ops.tensor_utils import convolve
  from pyro.util import warn_if_nan
label_desc: Use image node_id 4 for calling a global function with example usage: reparameterized_discrete_model(args, data) without return types