code: def _dense_num_jac(fun, t, y, f, h, factor, y_scale):
      n = y.shape[0]
      h_vecs = np.diag(h)
      f_new = fun(t, y[:, None] + h_vecs)
      diff = f_new - f[:, None]
      max_ind = np.argmax(np.abs(diff), axis=0)
      r = np.arange(n)
      max_diff = np.abs(diff[max_ind, r])
      scale = np.maximum(np.abs(f[max_ind]), np.abs(f_new[max_ind, r]))
  
      diff_too_small = max_diff < NUM_JAC_DIFF_REJECT * scale
      if np.any(diff_too_small):
          (ind,) = np.nonzero(diff_too_small)
          new_factor = NUM_JAC_FACTOR_INCREASE * factor[ind]
          h_new = (y[ind] + new_factor * y_scale[ind]) - y[ind]
          h_vecs[ind, ind] = h_new
          f_new = fun(t, y[:, None] + h_vecs[:, ind])
          diff_new = f_new - f[:, None]
          max_ind = np.argmax(np.abs(diff_new), axis=0)
          r = np.arange(ind.shape[0])
          max_diff_new = np.abs(diff_new[max_ind, r])
          scale_new = np.maximum(
              np.abs(f[max_ind]), np.abs(f_new[max_ind, r])
          )
  
          update = max_diff[ind] * scale_new < max_diff_new * scale[ind]
          if np.any(update):
              (update,) = np.nonzero(update)
              update_ind = ind[update]
              factor[update_ind] = new_factor[update]
              h[update_ind] = h_new[update]
              diff[:, update_ind] = diff_new[:, update]
              scale[update_ind] = scale_new[update]
              max_diff[update_ind] = max_diff_new[update]
  
      diff /= h
  
      factor[
          max_diff < NUM_JAC_DIFF_SMALL * scale
      ] *= NUM_JAC_FACTOR_INCREASE
      factor[
          max_diff > NUM_JAC_DIFF_BIG * scale
      ] *= NUM_JAC_FACTOR_DECREASE
      factor = np.maximum(factor, NUM_JAC_MIN_FACTOR)
  
      return diff, factor
  
file_path: catboost/contrib/python/scipy/py3/scipy/integrate/_ivp/common.py
imports: from itertools import groupby
  from warnings import warn
  import numpy
  from scipy.sparse import find, coo_matrix
label_desc: Use image node_id 8 for calling a global function with example usage: _dense_num_jac(fun, t, y, f, h, factor, y_scale) and returns: diff,  factor