class_docstr: A Solver class for the linear sum assignment (LSA) problem. 
  Designed for torch.jit.script compatibility in NeMo. 
      
  The LSA problem is also referred to as bipartite matching problem. An LSA problem is described 
  by a matrix `cost_mat`, where each cost_mat[i,j] is the cost of matching vertex i of the first partite 
  set (e.g. a "worker") and vertex j of the second set (e.g. a "job"). 
  
  Thus, the goal of LSA-solver is to find a complete assignment of column element to row element with 
  the minimal cost. Note that the solution may not be unique and there could be multiple solutions that 
  yield the same minimal cost.
  
  LSA problem solver is needed for the following tasks in NeMo: 
      - Permutation Invariant Loss (PIL) for diarization model training
      - Label permutation matching for online speaker diarzation 
      - Concatenated minimum-permutation Word Error Rate (cp-WER) calculation 
  
  This implementation is based on the LAP solver from scipy: 
      https://github.com/scipy/scipy/blob/v0.18.1/scipy/optimize/_hungarian.py
      The scipy implementation comes with the following license:
  
      Copyright (c) 2008 Brian M. Clapper <bmc@clapper.org>, Gael Varoquaux
      Author: Brian M. Clapper, Gael Varoquaux
      License: 3-clause BSD
  
  References
      1. http://csclab.murraystate.edu/bob.pilgrim/445/munkres.html
      2. https://en.wikipedia.org/wiki/Hungarian_algorithm
      3. https://github.com/scipy/scipy/blob/v0.18.1/scipy/optimize/_hungarian.py
  
  
  Attributes:
      cost_mat (Tensor): 2D matrix containing cost matrix. Number of columns must be larger than number of rows.
      row_uncovered (Tensor): 1D matrix containing boolean values indicating whether a row is covered.
      col_uncovered (Tensor): 1D matrix containing boolean values indicating whether a column is covered.
      zero_row (Tensor): 1D matrix containing the row index of the last zero found.
      zero_col (Tensor): 1D matrix containing the column index of the last zero found.
      path (Tensor): 2D matrix containing the path taken through the matrix.
      marked (Tensor): 2D matrix containing the marked zeros.
class_docstr_tok: ["A","Solver","class","for","the","linear","sum","assignment","(","LSA",")","problem",".","Designed","for","torch.jit.script","compatibility","in","NeMo",".","The","LSA","problem","is","also","referred","to","as","bipartite","matching","problem",".","An","LSA","problem","is","described","by","a","matrix","`","cost_mat","`",",","where","each","cost_mat","[","i",",","j","]","is","the","cost","of","matching","vertex","i","of","the","first","partite","set","(","e.g",".","a","``","worker","''",")","and","vertex","j","of","the","second","set","(","e.g",".","a","``","job","''",")",".","Thus",",","the","goal","of","LSA-solver","is","to","find","a","complete","assignment","of","column","element","to","row","element","with","the","minimal","cost",".","Note","that","the","solution","may","not","be","unique","and","there","could","be","multiple","solutions","that","yield","the","same","minimal","cost",".","LSA","problem","solver","is","needed","for","the","following","tasks","in","NeMo",":","-","Permutation","Invariant","Loss","(","PIL",")","for","diarization","model","training","-","Label","permutation","matching","for","online","speaker","diarzation","-","Concatenated","minimum-permutation","Word","Error","Rate","(","cp-WER",")","calculation","This","implementation","is","based","on","the","LAP","solver","from","scipy",":","https",":","\/\/github.com\/scipy\/scipy\/blob\/v0.18.1\/scipy\/optimize\/_hungarian.py","The","scipy","implementation","comes","with","the","following","license",":","Copyright","(","c",")","2008","Brian","M.","Clapper","<","bmc","@","clapper.org",">",",","Gael","Varoquaux","Author",":","Brian","M.","Clapper",",","Gael","Varoquaux","License",":","3-clause","BSD","References","1.","http",":","\/\/csclab.murraystate.edu\/bob.pilgrim\/445\/munkres.html","2.","https",":","\/\/en.wikipedia.org\/wiki\/Hungarian_algorithm","3.","https",":","\/\/github.com\/scipy\/scipy\/blob\/v0.18.1\/scipy\/optimize\/_hungarian.py","Attributes",":","cost_mat","(","Tensor",")",":","2D","matrix","containing","cost","matrix",".","Number","of","columns","must","be","larger","than","number","of","rows",".","row_uncovered","(","Tensor",")",":","1D","matrix","containing","boolean","values","indicating","whether","a","row","is","covered",".","col_uncovered","(","Tensor",")",":","1D","matrix","containing","boolean","values","indicating","whether","a","column","is","covered",".","zero_row","(","Tensor",")",":","1D","matrix","containing","the","row","index","of","the","last","zero","found",".","zero_col","(","Tensor",")",":","1D","matrix","containing","the","column","index","of","the","last","zero","found",".","path","(","Tensor",")",":","2D","matrix","containing","the","path","taken","through","the","matrix",".","marked","(","Tensor",")",":","2D","matrix","containing","the","marked","zeros","."]
code: def __init__(self, cost_matrix: torch.Tensor):
      # The main cost matrix
      self.cost_mat = cost_matrix
      row_len, col_len = self.cost_mat.shape
  
      # Initialize the solver state
      self.zero_row = torch.tensor(0, dtype=torch.long).to(
          cost_matrix.device
      )
      self.zero_col = torch.tensor(0, dtype=torch.long).to(
          cost_matrix.device
      )
  
      # Initialize the covered matrices
      self.row_uncovered = torch.ones(row_len, dtype=torch.bool).to(
          cost_matrix.device
      )
      self.col_uncovered = torch.ones(col_len, dtype=torch.bool).to(
          cost_matrix.device
      )
  
      # Initialize the path matrix and the mark matrix
      self.path = torch.zeros(
          (row_len + col_len, 2), dtype=torch.long
      ).to(cost_matrix.device)
      self.marked = torch.zeros(
          (row_len, col_len), dtype=torch.long
      ).to(cost_matrix.device)
  
file_path: NeMo/nemo/collections/asr/parts/utils/optimization_utils.py
imports: import torch
label_desc: Use image node_id 1 to create a new LinearSumAssignmentSolver object from inherited base classes: object with example: obj = LinearSumAssignmentSolver(cost_matrix)