code: def test_persistent_independent_subproblems(
      num_objects, num_frames, num_detections, bp_iters
  ):
      # solve a random assignment problem
      exists_logits_1 = -2 * torch.rand(num_objects)
      assign_logits_1 = (
          2 * torch.rand(num_frames, num_detections, num_objects) - 1
      )
      assignment_1 = MarginalAssignmentPersistent(
          exists_logits_1, assign_logits_1, bp_iters
      )
      exists_probs_1 = assignment_1.exists_dist.probs
      assign_probs_1 = assignment_1.assign_dist.probs
  
      # solve another random assignment problem
      exists_logits_2 = -2 * torch.rand(num_objects)
      assign_logits_2 = (
          2 * torch.rand(num_frames, num_detections, num_objects) - 1
      )
      assignment_2 = MarginalAssignmentPersistent(
          exists_logits_2, assign_logits_2, bp_iters
      )
      exists_probs_2 = assignment_2.exists_dist.probs
      assign_probs_2 = assignment_2.assign_dist.probs
  
      # solve a unioned assignment problem
      exists_logits = torch.cat([exists_logits_1, exists_logits_2])
      assign_logits = torch.full(
          (num_frames, num_detections * 2, num_objects * 2), -INF
      )
      assign_logits[:, :num_detections, :num_objects] = assign_logits_1
      assign_logits[:, num_detections:, num_objects:] = assign_logits_2
      assignment = MarginalAssignmentPersistent(
          exists_logits, assign_logits, bp_iters
      )
      exists_probs = assignment.exists_dist.probs
      assign_probs = assignment.assign_dist.probs
  
      # check agreement
      assert_equal(exists_probs_1, exists_probs[:num_objects])
      assert_equal(exists_probs_2, exists_probs[num_objects:])
      assert_equal(
          assign_probs_1[:, :, :-1],
          assign_probs[:, :num_detections, :num_objects],
      )
      assert_equal(
          assign_probs_1[:, :, -1], assign_probs[:, :num_detections, -1]
      )
      assert_equal(
          assign_probs_2[:, :, :-1],
          assign_probs[:, num_detections:, num_objects:-1],
      )
      assert_equal(
          assign_probs_2[:, :, -1], assign_probs[:, num_detections:, -1]
      )
  
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 17 for calling a global function with example usage: test_persistent_independent_subproblems(num_objects, num_frames, num_detections, bp_iters) without return types