assignment.hungarian_assignment
def hungarian_assignment(cost_matrix: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]Solve a LAP via SciPy's Hungarian implementation.
Copies the cost matrix to host, calls
:func:`scipy.optimize.linear_sum_assignment`, and returns the result
as PyTorch tensors on the original device.
Parameters
| Name | Type | Description |
|---|---|---|
| cost_matrix | torch.Tensor | ``(N, M)`` cost matrix. ``inf`` entries mark forbidden pairs; ``NaN`` entries raise. |
Returns
torch.Tensor — ``(K, 2)`` long tensor of matched ``(row, col)`` indices.
Raises
- ValueError — If the cost matrix contains ``NaN``.
Source: unitrack/assignment/_hungarian.py:39