code: def guide(detections, args):
      noise_scale = pyro.param("noise_scale")  # trained by SVI
      objects = pyro.param("objects_loc").squeeze(
          -1
      )  # trained by M-step of EM
      (num_detections,) = detections.shape
      (max_num_objects,) = objects.shape
  
      with torch.set_grad_enabled(args.assignment_grad):
          # Evaluate log likelihoods. TODO make this more pyronic.
          exists_logits = compute_exists_logits(objects, args)
          assign_logits = compute_assign_logits(
              objects, detections.unsqueeze(-1), noise_scale, args
          )
          assert exists_logits.shape == (max_num_objects,)
          assert assign_logits.shape == (
              num_detections,
              max_num_objects,
          )
  
          # Compute soft assignments.
          assignment = MarginalAssignment(
              exists_logits, assign_logits, bp_iters=10
          )
  
      with pyro.plate("objects_plate", max_num_objects):
          pyro.sample(
              "exists",
              assignment.exists_dist,
              infer={"enumerate": "parallel"},
          )
      with pyro.plate("detections_plate", num_detections):
          pyro.sample(
              "assign",
              assignment.assign_dist,
              infer={"enumerate": "parallel"},
          )
  
imports: import logging
  import math
  import pytest
  import torch
  from torch.distributions import constraints
  import pyro
  import pyro.distributions
  import pyro.poutine
  from pyro.contrib.tracking.assignment import MarginalAssignment
  from pyro.infer import SVI, TraceEnum_ELBO
  from pyro.optim import Adam
  from pyro.optim.multi import MixedMultiOptimizer, Newton
label_desc: Use image node_id 5 for calling a global function with example usage: guide(detections, args) without return types