code: def generate_data(args):
      logging.info("Generating data...")
      params = {
          "R0": torch.tensor(args.basic_reproduction_number),
          "rho": torch.tensor(args.response_rate),
      }
      empty_data = [None] * (args.duration + args.forecast)
  
      # We'll retry until we get an actual outbreak.
      for attempt in range(100):
          with poutine.trace() as tr:
              with poutine.condition(data=params):
                  discrete_model(args, empty_data)
  
          # Concatenate sequential time series into tensors.
          obs = torch.stack(
              [
                  site["value"]
                  for name, site in tr.trace.nodes.items()
                  if re.match("obs_[0-9]+", name)
              ]
          )
          S2I = torch.stack(
              [
                  site["value"]
                  for name, site in tr.trace.nodes.items()
                  if re.match("S2I_[0-9]+", name)
              ]
          )
          assert len(obs) == len(empty_data)
  
          obs_sum = int(obs[: args.duration].sum())
          S2I_sum = int(S2I[: args.duration].sum())
          if obs_sum >= args.min_observations:
              logging.info(
                  "Observed {:d}/{:d} infections:\n{}".format(
                      obs_sum,
                      S2I_sum,
                      " ".join(
                          [str(int(x)) for x in obs[: args.duration]]
                      ),
                  )
              )
              return {"S2I": S2I, "obs": obs}
  
      raise ValueError(
          "Failed to generate {} observations. Try increasing "
          "--population or decreasing --min-observations".format(
              args.min_observations
          )
      )
  
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 3 for calling a global function with example usage: generate_data(args) and returns: dict