code: def fuse_motion(
      kf,
      cost_matrix,
      tracks,
      detections,
      only_position=False,
      lambda_=0.98,
  ):
      if cost_matrix.size == 0:
          return cost_matrix
      gating_dim = 2 if only_position else 4
      gating_threshold = kalman_filter.chi2inv95[gating_dim]
      measurements = np.asarray([det.to_xyah() for det in detections])
      for row, track in enumerate(tracks):
          gating_distance = kf.gating_distance(
              track.mean,
              track.covariance,
              measurements,
              only_position,
              metric="maha",
          )
          cost_matrix[row, gating_distance > gating_threshold] = np.inf
          cost_matrix[row] = (
              lambda_ * cost_matrix[row]
              + (1 - lambda_) * gating_distance
          )
      return cost_matrix
  
file_path: PaddleDetection/ppdet/modeling/mot/matching/jde_matching.py
imports: import scipy
  import numpy
  from scipy.spatial.distance import cdist
  from ..motion import kalman_filter
  import warnings
label_desc: Use image node_id 6 for calling a global function with example usage: fuse_motion(kf, cost_matrix, tracks, detections, only_position, lambda_) and returns: cost_matrix, cost_matrix