code: def test_sparse_smoke():
      num_objects = 4
      num_detections = 2
      pyro.set_rng_seed(0)
      exists_logits = torch.zeros(num_objects)
      edges = exists_logits.new_tensor(
          [
              [0, 0, 1, 0, 1, 0],
              [0, 1, 1, 2, 2, 3],
          ],
          dtype=torch.long,
      )
      assign_logits = logit(
          torch.tensor([0.99, 0.8, 0.2, 0.2, 0.8, 0.9])
      )
      assert assign_logits.shape == edges.shape[1:]
  
      solver = MarginalAssignmentSparse(
          num_objects,
          num_detections,
          edges,
          exists_logits,
          assign_logits,
          bp_iters=5,
      )
  
      assert solver.exists_dist.batch_shape == (num_objects,)
      assert solver.exists_dist.event_shape == ()
      assert solver.assign_dist.batch_shape == (num_detections,)
      assert solver.assign_dist.event_shape == ()
      assert (
          solver.assign_dist.probs.shape[-1] == num_objects + 1
      )  # true + spurious
  
      # test dense matches sparse
      assign_logits = sparse_to_dense(
          num_objects, num_detections, edges, assign_logits
      )
      other = MarginalAssignment(
          exists_logits, assign_logits, bp_iters=5
      )
      assert_equal(
          other.exists_dist.probs, solver.exists_dist.probs, prec=1e-3
      )
      assert_equal(
          other.assign_dist.probs, solver.assign_dist.probs, prec=1e-3
      )
  
imports: import logging
  import pytest
  import torch
  from torch.autograd import grad
  import pyro
  import pyro.distributions
  from pyro.contrib.tracking.assignment import MarginalAssignment, MarginalAssignmentPersistent, MarginalAssignmentSparse
  from tests.common import assert_equal
label_desc: Use image node_id 6 for calling a global function with example usage: test_sparse_smoke() without return types