code: def _check_lipschitz_continuous(
      f, ndim, lipschitz_constant, n_trials=10, random_state=42
  ):
      """Empirically check Lipschitz continuity of a function.
  
      If this test is passed, then we are empirically confident in the
      Lipschitz continuity of the function with respect to the given
      constant `L`. This confidence increases with the `n_trials` parameter.
  
      Parameters
      ----------
      f : callable,
        The function to be checked for Lipschitz continuity.
        `f` takes a vector of float as unique argument.
        The size of the input vector is determined by `ndim`.
  
      ndim : int,
        Dimension of the input of the function to be checked for Lipschitz
        continuity (i.e. it corresponds to the size of the vector that `f`
        takes as an argument).
  
      lispchitz_constant : float,
        Constant associated to the Lipschitz continuity.
  
      n_trials : int,
        Number of tests performed when assessing the Lipschitz continuity of
        function `f`. The more tests, the more confident we are in the
        Lipschitz continuity of `f` if the test passes.
  
      random_state : int, optional (default 42)
          Random state for initializing local rng.
  
      Raises
      ------
      RuntimeError
      """
      rng = np.random.default_rng(random_state)
      for x in rng.standard_normal((n_trials, ndim)):
          for y in rng.standard_normal((n_trials, ndim)):
              a = linalg.norm(f(x).ravel() - f(y).ravel(), 2)
              b = lipschitz_constant * linalg.norm(x - y, 2)
              if a > b:
                  raise RuntimeError(f"Counter example: ({x}, {y})")
  
imports: from math import sqrt
  import numpy
  from scipy import linalg
label_desc: Use image node_id 1 for calling a global function with example usage: _check_lipschitz_continuous(f, ndim, lipschitz_constant, n_trials, random_state) without return types