code: def test_em(assignment_grad):
      args = make_args()
      args.assignment_grad = assignment_grad
      detections = generate_data(args)
  
      pyro.clear_param_store()
      pyro.param(
          "noise_scale",
          torch.tensor(args.init_noise_scale),
          constraint=constraints.positive,
      )
      pyro.param("objects_loc", torch.randn(args.max_num_objects, 1))
  
      # Learn object_loc via EM algorithm.
      elbo = TraceEnum_ELBO(max_plate_nesting=2)
      newton = Newton(trust_radii={"objects_loc": 1.0})
      for step in range(10):
          # Detach previous iterations.
          objects_loc = (
              pyro.param("objects_loc").detach_().requires_grad_()
          )
          loss = elbo.differentiable_loss(
              model, guide, detections, args
          )  # E-step
          newton.step(loss, {"objects_loc": objects_loc})  # M-step
          logger.debug("step {}, loss = {}".format(step, loss.item()))
  
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 7 for calling a global function with example usage: test_em(assignment_grad) without return types