code: def lb_keogh(
      ts_query, ts_candidate=None, radius=1, envelope_candidate=None
  ):
      r"""Compute LB_Keogh.
  
      LB_Keogh was originally presented in [1]_.
  
      Parameters
      ----------
      ts_query : array-like, shape=(sz1, 1) or (sz1,)
          Univariate query time-series to compare to the envelope of the candidate.
      ts_candidate : None or array-like, shape=(sz2, 1) or (sz2,) (default: None)
          Univariate candidate time-series. None means the envelope is provided via
          `envelope_candidate` parameter and hence does not
          need to be computed again.
      radius : int (default: 1)
          Radius to be used for the envelope generation (the envelope at time
          index i will be generated based on
          all observations from the candidate time series at indices comprised
          between i-radius and i+radius). Not used
          if `ts_candidate` is None.
      envelope_candidate: pair of array-like (envelope_down, envelope_up) or None
      (default: None)
          Pre-computed envelope of the candidate time series. If set to None, it
          is computed based on `ts_candidate`.
  
      Notes
      -----
          This method requires a `ts_query` and `ts_candidate` (or
          `envelope_candidate`, depending on the call) to be of equal size.
  
      Returns
      -------
      float
          Distance between the query time series and the envelope of the
          candidate time series.
  
      Examples
      --------
      >>> ts1 = [1, 2, 3, 2, 1]
      >>> ts2 = [0, 0, 0, 0, 0]
      >>> env_low, env_up = lb_envelope(ts1, radius=1)
      >>> lb_keogh(ts_query=ts2,
      ...          envelope_candidate=(env_low, env_up))  # doctest: +ELLIPSIS
      2.8284...
      >>> lb_keogh(ts_query=ts2,
      ...          ts_candidate=ts1,
      ...          radius=1)  # doctest: +ELLIPSIS
      2.8284...
  
      See also
      --------
      lb_envelope : Compute LB_Keogh-related envelope
  
      References
      ----------
      .. [1] Keogh, E. Exact indexing of dynamic time warping. In International
         Conference on Very Large Data Bases, 2002. pp 406-417.
      """
      if ts_candidate is None:
          envelope_down, envelope_up = envelope_candidate
      else:
          ts_candidate = to_time_series(ts_candidate)
          assert (
              ts_candidate.shape[1] == 1
          ), "LB_Keogh is available only for univariate time series"
          envelope_down, envelope_up = lb_envelope(ts_candidate, radius)
      ts_query = to_time_series(ts_query)
      assert (
          ts_query.shape[1] == 1
      ), "LB_Keogh is available only for univariate time series"
      indices_up = ts_query[:, 0] > envelope_up[:, 0]
      indices_down = ts_query[:, 0] < envelope_down[:, 0]
      return numpy.sqrt(
          numpy.linalg.norm(
              ts_query[indices_up, 0] - envelope_up[indices_up, 0]
          )
          ** 2
          + numpy.linalg.norm(
              ts_query[indices_down, 0] - envelope_down[indices_down, 0]
          )
          ** 2
      )
  
imports: import warnings
  import numpy
  from numba import njit, prange
  from tslearn.backend import instantiate_backend
  from tslearn.utils import to_time_series
  from .utils import _cdist_generic
label_desc: Use image node_id 33 for calling a global function with example usage: lb_keogh(ts_query, ts_candidate, radius, envelope_candidate) and returns: numpy