code: def dense_to_sparse(assign_logits):
      num_detections, num_objects = assign_logits.shape
      edges = assign_logits.new_tensor(
          [
              [j, i]
              for j in range(num_detections)
              for i in range(num_objects)
          ],
          dtype=torch.long,
      ).t()
      assign_logits = assign_logits[edges[0], edges[1]]
      return edges, assign_logits
  
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 3 for calling a global function with example usage: dense_to_sparse(assign_logits) and returns: edges,  assign_logits