code: def generate_data(args):
      extended_data = [None] * (args.duration + args.forecast)
      model = Model(args, extended_data)
      logging.info("Simulating from a {}".format(type(model).__name__))
      for attempt in range(100):
          samples = model.generate(
              {
                  "R0": args.basic_reproduction_number,
                  "rho_c1": 10 * args.response_rate,
                  "rho_c0": 10 * (1 - args.response_rate),
              }
          )
          obs = samples["obs"][: args.duration]
          S2I = samples["S2I"]
  
          obs_sum = int(obs.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[:, 0]),
                  )
              )
              return {"S2I": S2I, "obs": obs}
  
      raise ValueError(
          "Failed to generate {} observations. Try increasing "
          "--population or decreasing --min-observations".format(
              args.min_observations
          )
      )
  
file_path: pyro/examples/contrib/epidemiology/regional.py
imports: import argparse
  import logging
  import torch
  import pyro
  from pyro.contrib.epidemiology.models import RegionalSIRModel
label_desc: Use image node_id 2 for calling a global function with example usage: generate_data(args) and returns: dict