code: def main(args):
      # Create a model, synthetic data, a guide, and a lightning module.
      pyro.set_rng_seed(args.seed)
      pyro.settings.set(module_local_params=True)
      model = Model(args.size)
      covariates = torch.randn(args.size)
      data = model(covariates)
      guide = AutoNormal(model)
      loss_fn = Trace_ELBO()(model, guide)
      training_plan = PyroLightningModule(loss_fn, args.learning_rate)
  
      # Create a dataloader.
      dataset = torch.utils.data.TensorDataset(covariates, data)
      dataloader = torch.utils.data.DataLoader(
          dataset, batch_size=args.batch_size
      )
  
      # All relevant parameters need to be initialized before ``configure_optimizer`` is called.
      # Since we used AutoNormal guide our parameters have not be initialized yet.
      # Therefore we initialize the model and guide by running one mini-batch through the loss.
      mini_batch = dataset[: args.batch_size]
      loss_fn(*mini_batch)
  
      # Run stochastic variational inference using PyTorch Lightning Trainer.
      trainer = pl.Trainer(
          accelerator=args.accelerator,
          strategy=args.strategy,
          devices=args.devices,
          max_epochs=args.max_epochs,
      )
      trainer.fit(training_plan, train_dataloaders=dataloader)
  
file_path: pyro/examples/svi_lightning.py
imports: import argparse
  import lightning.pytorch
  import torch
  import pyro
  import pyro.distributions
  from pyro.infer import Trace_ELBO
  from pyro.infer.autoguide import AutoNormal
  from pyro.nn import PyroModule
label_desc: Use image node_id 1 for calling a global function with example usage: main(args) without return types