code: def _aamp_ostinato(
      Ts,
      m,
      Ts_subseq_isfinite,
      p=2.0,
      client=None,
      device_id=None,
      mp_func=aamp,
  ):
      """
      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
  
      Ts_subseq_isfinite : list
          A list of rolling window `T_subseq_isfinite` for each time series in `Ts`
  
      p : float, default 2.0
          The p-norm to apply for computing the Minkowski distance. Minkowski distance is
          typically used with `p` being 1 or 2, which correspond to the Manhattan distance
          and the Euclidean distance, respectively.
  
      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, p=p
          )
          si = np.argsort(mp[:, 0])
          for q in si:
              Q = Ts[j][q : q + m]
              radius = mp[q, 0]
              if radius >= bsf_radius:
                  break
              for i in range(k):
                  if i != j and i != h:
                      if np.any(~np.isfinite(Q)):  # pragma: no cover
                          distance_profile = np.full(
                              Ts[i].shape[0] - m + 1, np.inf
                          )
                      else:
                          distance_profile = core.mass_absolute(
                              Q, Ts[i], Ts_subseq_isfinite[i], p=p
                          )
                      radius = np.max(
                          (radius, np.min(distance_profile))
                      )
                      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/aamp_ostinato.py
imports: import numpy
  from .None import core
  from .aamp import aamp
  from .aamped import aamped
label_desc: Use image node_id 3 for calling a global function with example usage: _aamp_ostinato(Ts, m, Ts_subseq_isfinite, p, client, device_id, mp_func) and returns: bsf_radius,  bsf_Ts_idx,  bsf_subseq_idx