code: def const_vel_filter_2d(
      dt, x_ndim=1, P_diag=(1.0, 1, 1, 1), R_std=1.0, Q_var=0.0001
  ):
      """helper, constructs 1d, constant velocity filter"""
  
      kf = KalmanFilter(dim_x=4, dim_z=2)
  
      kf.x = np.array([[0.0, 0.0, 0.0, 0.0]]).T
      kf.P *= np.diag(P_diag)
      kf.F = np.array(
          [
              [1.0, dt, 0.0, 0.0],
              [0.0, 1.0, 0.0, 0.0],
              [0.0, 0.0, 1.0, dt],
              [0.0, 0.0, 0.0, 1.0],
          ]
      )
  
      kf.H = np.array([[1.0, 0, 0, 0], [0.0, 0, 1, 0]])
  
      kf.R *= np.eye(2) * (R_std**2)
      q = Q_discrete_white_noise(dim=2, dt=dt, var=Q_var)
      kf.Q = block_diag(q, q)
  
      return kf
  
imports: from __future__ import absolute_import, division, print_function
  import numpy.random
  from numpy.random import randn
  import numpy
  import matplotlib.pyplot
  from pytest import approx
  from filterpy.kalman import KalmanFilter, update, predict, batch_filter
  from filterpy.common import Q_discrete_white_noise, kinematic_kf, Saver
  from filterpy.stats import mahalanobis
  from scipy.linalg import block_diag, norm
label_desc: Use image node_id 2 for calling a global function with example usage: const_vel_filter_2d(dt, x_ndim, P_diag, R_std, Q_var) and returns: kf