code: def _root(function, N, args, x):
      # The right bound is at most 0.01
      found = False
      N = max(min(1050, N), 50)
      tol = 10e-12 + 0.01 * (N - 50) / 1000
  
      while not found:
          try:
              bw, res = brentq(
                  function,
                  0,
                  0.01,
                  args=args,
                  full_output=True,
                  disp=False,
              )
              found = res.converged
          except ValueError:
              bw = 0
              tol *= 2.0
              found = False
          if bw <= 0 or tol >= 1:
              bw = (_bw_silverman(x) / np.ptp(x)) ** 2
              return bw
      return bw
  
imports: import warnings
  import numpy
  from scipy.fftpack import fft
  from scipy.optimize import brentq
  from scipy.signal import convolve, convolve2d, gaussian
  from scipy.sparse import coo_matrix
  from scipy.special import ive
  from ..utils import _cov, _dot, _stack, conditional_jit
label_desc: Use image node_id 12 for calling a global function with example usage: _root(function, N, args, x) and returns: bw, bw