code: def stop_criterion(thetaminus, thetaplus, rminus, rplus):
      """Compute the stop condition in the main loop
      dot(dtheta, rminus) >= 0 & dot(dtheta, rplus >= 0)
  
      Parameters
      ------
      thetaminus: ndarray[float, ndim=1]
          under position
      thetaplus: ndarray[float, ndim=1]
          above position
      rminus: ndarray[float, ndim=1]
          under momentum
      rplus: ndarray[float, ndim=1]
          above momentum
  
      Returns
      -------
      criterion: bool
          whether the condition is valid
      """
      dtheta = thetaplus - thetaminus
      return (np.dot(dtheta, rminus.T) >= 0) & (
          np.dot(dtheta, rplus.T) >= 0
      )
  
imports: import numpy
  import matplotlib.pyplot
  import scipy.special
  import scipy.stats
label_desc: Use image node_id 1 for calling a global function with example usage: stop_criterion(thetaminus, thetaplus, rminus, rplus) and returns: unknown