class_docstr: A nearest neighbor distance metric that, for each target, returns
  the closest distance to any sample that has been observed so far.
  
  Args:
      metric (str): Either "euclidean" or "cosine".
      matching_threshold (float): The matching threshold. Samples with larger
          distance are considered an invalid match.
      budget (Optional[int]): If not None, fix samples per class to at most
          this number. Removes the oldest samples when the budget is reached.
  
  Attributes:
      samples (Dict[int -> List[ndarray]]): A dictionary that maps from target
          identities to the list of samples that have been observed so far.
docstr: Compute distance between features and targets.
  
  Args:
      features (ndarray): An NxM matrix of N features of dimensionality M.
      targets (list[int]): A list of targets to match the given `features` against.
  
  Returns:
      cost_matrix (ndarray): a cost matrix of shape len(targets), len(features),
          where element (i, j) contains the closest squared distance between
          `targets[i]` and `features[j]`.
docstr_tok: ["Compute","distance","between","features","and","targets",".","Args",":","features","(","ndarray",")",":","An","NxM","matrix","of","N","features","of","dimensionality","M.","targets","(","list","[","int","]",")",":","A","list","of","targets","to","match","the","given","`","features","`","against",".","Returns",":","cost_matrix","(","ndarray",")",":","a","cost","matrix","of","shape","len","(","targets",")",",","len","(","features",")",",","where","element","(","i",",","j",")","contains","the","closest","squared","distance","between","`","targets","[","i","]","`","and","`","features","[","j","]","`","."]
code: def distance(self, features, targets):
      """
      Compute distance between features and targets.
  
      Args:
          features (ndarray): An NxM matrix of N features of dimensionality M.
          targets (list[int]): A list of targets to match the given `features` against.
  
      Returns:
          cost_matrix (ndarray): a cost matrix of shape len(targets), len(features),
              where element (i, j) contains the closest squared distance between
              `targets[i]` and `features[j]`.
      """
      cost_matrix = np.zeros((len(targets), len(features)))
      for i, target in enumerate(targets):
          cost_matrix[i, :] = self._metric(
              self.samples[target], features
          )
      return cost_matrix
  
file_path: PaddleHub/modules/video/multiple_object_tracking/jde_darknet53/modeling/mot/matching/deepsort_matching.py
imports: import numpy
  from scipy.optimize import linear_sum_assignment
  from ..motion import kalman_filter
label_desc: Use image node_id 3 for calling the NearestNeighborDistanceMetric obj's underlying member method code with example usage: obj.distance(features, targets) and returns: cost_matrix