code: def _ostinato(
      Ts,
      m,
      M_Ts,
      Σ_Ts,
      Ts_subseq_isconstant,
      client=None,
      device_id=None,
      mp_func=stump,
  ):
      """
      Find the consensus motif amongst a list of time series
  
      Parameters
      ----------
      Ts : list
          A list of time series for which to find the consensus motif
  
      m : int
          Window size
  
      M_Ts : list
          A list of rolling window means for each time series in `Ts`
  
      Σ_Ts : list
          A list of rolling window standard deviations for each time series in `Ts`
  
      Ts_subseq_isconstant : list
          A list of rolling window isconstant for each time series in `Ts`
  
      client : client, default None
          A Dask or Ray Distributed client. Setting up a distributed cluster is beyond
          the scope of this library. Please refer to the Dask or Ray Distributed
          documentation.
  
      device_id : int or list, default None
          The (GPU) device number to use. The default value is `0`. A list of
          valid device ids (int) may also be provided for parallel GPU-STUMP
          computation. A list of all valid device ids can be obtained by
          executing `[device.id for device in numba.cuda.list_devices()]`.
  
      mp_func : function, default stump
          Specify a custom matrix profile function to use for computing matrix profiles
  
      Returns
      -------
      bsf_radius : float
          The (best-so-far) Radius of the consensus motif
  
      bsf_Ts_idx : int
          The time series index in `Ts` which contains the consensus motif
  
      bsf_subseq_idx : int
          The subsequence index within time series `Ts[bsf_Ts_idx]` the contains the
          consensus motif
  
      Notes
      -----
      `DOI: 10.1109/ICDM.2019.00140 \
      <https://www.cs.ucr.edu/~eamonn/consensus_Motif_ICDM_Long_version.pdf>`__
  
      See Table 2
  
      The ostinato algorithm proposed in the paper finds the best radius
      in `Ts`. Intuitively, the radius is the minimum distance of a
      subsequence to encompass at least one nearest neighbor subsequence
      from all other time series. The best radius in `Ts` is the minimum
      radius amongst all radii. Some data sets might contain multiple
      subsequences which have the same optimal radius.
      The greedy Ostinato algorithm only finds one of them, which might
      not be the most central motif. The most central motif amongst the
      subsequences with the best radius is the one with the smallest mean
      distance to nearest neighbors in all other time series. To find this
      central motif it is necessary to search the subsequences with the
      best radius via `stumpy.ostinato._get_central_motif`
      """
      bsf_radius = np.inf
      bsf_Ts_idx = 0
      bsf_subseq_idx = 0
  
      partial_mp_func = core._get_partial_mp_func(
          mp_func, client=client, device_id=device_id
      )
  
      k = len(Ts)
      for j in range(k):
          if j < (k - 1):
              h = j + 1
          else:
              h = 0
  
          mp = partial_mp_func(
              Ts[j],
              m,
              Ts[h],
              ignore_trivial=False,
              T_A_subseq_isconstant=Ts_subseq_isconstant[j],
              T_B_subseq_isconstant=Ts_subseq_isconstant[h],
          )
          si = np.argsort(mp[:, 0])
          for q in si:
              radius = mp[q, 0]
              if radius >= bsf_radius:
                  break
              for i in range(k):
                  if i != j and i != h:
                      QT = core.sliding_dot_product(
                          Ts[j][q : q + m], Ts[i]
                      )
                      radius = np.max(
                          (
                              radius,
                              np.min(
                                  core._mass(
                                      Ts[j][q : q + m],
                                      Ts[i],
                                      QT,
                                      M_Ts[j][q],
                                      Σ_Ts[j][q],
                                      M_Ts[i],
                                      Σ_Ts[i],
                                      Ts_subseq_isconstant[j][q],
                                      Ts_subseq_isconstant[i],
                                  )
                              ),
                          )
                      )
                      if radius >= bsf_radius:
                          break
              if radius < bsf_radius:
                  bsf_radius, bsf_Ts_idx, bsf_subseq_idx = radius, j, q
  
      return bsf_radius, bsf_Ts_idx, bsf_subseq_idx
  
file_path: stumpy/stumpy/ostinato.py
imports: import numpy
  from .None import core
  from .aamp_ostinato import aamp_ostinato, aamp_ostinatoed
  from .stump import stump
  from .stumped import stumped
label_desc: Use image node_id 3 for calling a global function with example usage: _ostinato(Ts, m, M_Ts, Σ_Ts, Ts_subseq_isconstant, client, device_id, mp_func) and returns: bsf_radius,  bsf_Ts_idx,  bsf_subseq_idx