class_docstr: Base model for object detection or instance segmentation with matching.
  
  This model implements the classification and matching parts which are shared
  between the object detection and instance segmentation models.
docstr: Implements a matching function.
  
  Matching function matches output detections against ground truth detections
   and returns indices.
  
  Args:
    cost: Matching cost matrix
    n_cols: Number of non-padded columns in each cost matrix.
  
  Returns:
    Matched indices which in the form of a list  of tuples (src, dst), where
    `src` and `dst` are indices of corresponding source and target detections.
docstr_tok: ["Implements","a","matching","function",".","Matching","function","matches","output","detections","against","ground","truth","detections","and","returns","indices",".","Args",":","cost",":","Matching","cost","matrix","n_cols",":","Number","of","non-padded","columns","in","each","cost","matrix",".","Returns",":","Matched","indices","which","in","the","form","of","a","list","of","tuples","(","src",",","dst",")",",","where","`","src","`","and","`","dst","`","are","indices","of","corresponding","source","and","target","detections","."]
code: def matcher(
      self, cost: jnp.ndarray, n_cols: Optional[jnp.ndarray] = None
  ) -> jnp.ndarray:
      """Implements a matching function.
  
      Matching function matches output detections against ground truth detections
       and returns indices.
  
      Args:
        cost: Matching cost matrix
        n_cols: Number of non-padded columns in each cost matrix.
  
      Returns:
        Matched indices which in the form of a list  of tuples (src, dst), where
        `src` and `dst` are indices of corresponding source and target detections.
      """
      matcher_name, matcher_fn = self.config.get("matcher"), None
      if matcher_name == "lazy":
          matcher_fn = matchers.lazy_matcher
      elif matcher_name == "sinkhorn":
          matcher_fn = functools.partial(
              matchers.sinkhorn_matcher,
              epsilon=self.config.get("sinkhorn_epsilon", 0.001),
              init=self.config.get("sinkhorn_init", 50),
              decay=self.config.get("sinkhorn_decay", 0.9),
              num_iters=self.config.get("sinkhorn_num_iters", 1000),
              threshold=self.config.get("sinkhorn_threshold", 1e-2),
              chg_momentum_from=self.config.get(
                  "sinkhorn_chg_momentum_from", 100
              ),
              num_permutations=self.config.get(
                  "sinkhorn_num_permutations", 100
              ),
          )
  
      elif matcher_name == "greedy":
          matcher_fn = matchers.greedy_matcher
      elif matcher_name == "hungarian":
          matcher_fn = functools.partial(
              matchers.hungarian_matcher, n_cols=n_cols
          )
      elif matcher_name == "hungarian_tpu":
          matcher_fn = matchers.hungarian_tpu_matcher
      elif matcher_name == "hungarian_scan_tpu":
          matcher_fn = matchers.hungarian_scan_tpu_matcher
      elif matcher_name == "hungarian_cover_tpu":
          matcher_fn = matchers.hungarian_cover_tpu_matcher
      else:
          raise ValueError("Unknown matcher (%s)." % matcher_name)
  
      return jax.lax.stop_gradient(matcher_fn(cost))
  
imports: import abc
  import functools
  from typing import Any, Callable, Dict, Optional, Tuple
  import jax
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.model_lib import matchers
  from scenic.model_lib.base_models import base_model
  from scenic.model_lib.base_models import box_utils
  from scenic.model_lib.base_models import model_utils
label_desc: Use image node_id 4 for calling the BaseModelWithMatching obj's underlying member method code with example usage: obj.matcher(cost, n_cols) and returns: jax