code: def aamp_match(
      Q,
      T,
      T_subseq_isfinite=None,
      max_distance=None,
      max_matches=None,
      atol=1e-8,
      query_idx=None,
      p=2.0,
  ):
      """
      Find all matches of a query `Q` in a time series `T`, i.e. the indices
      of subsequences whose distances to `Q` are less or equal to
      `max_distance`, sorted by distance (lowest to highest).
  
      Around each occurrence an exclusion zone is applied before searching for the next.
  
      Parameters
      ----------
      Q : numpy.ndarray
          The query sequence. It doesn't have to be a subsequence of `T`
  
      T : numpy.ndarray
          The time series of interest
  
      T_subseq_isfinite : numpy.ndarray, default None
          A boolean array that indicates whether a subsequence in `T` contains a
          `np.nan`/`np.inf` value (False)
  
      max_distance : float or function, default None
          Maximum distance between `Q` and a subsequence `S` for `S` to be considered a
          match. If a function, then it has to be a function of one argument `D`, which
          will be the distance profile of `Q` with `T` (a 1D numpy array of size `n-m+1`).
          If None, defaults to
          `np.nanmax([np.nanmean(D) - 2 * np.nanstd(D), np.nanmin(D)])` (i.e. at
          least the closest match will be returned).
  
      max_matches : int, default None
          The maximum amount of similar occurrences to be returned. The resulting
          occurrences are sorted by distance, so a value of `10` means that the
          indices of the most similar `10` subsequences is returned. If `None`, then all
          occurrences are returned.
  
      atol : float, default 1e-8
          The absolute tolerance parameter. This value will be added to `max_distance`
          when comparing distances between subsequences.
  
      query_idx : int, default None
          This is the index position along the time series, `T`, where the query
          subsequence, `Q`, is located.
          `query_idx` should only be used when the matrix profile is a self-join and
          should be set to `None` for matrix profiles computed from AB-joins.
          If `query_idx` is set to a specific integer value, then this will help ensure
          that the self-match will be returned first.
  
      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.
  
      Returns
      -------
      out : numpy.ndarray
          The first column consists of distances of subsequences of `T` whose distances
          to `Q` are less than or equal to`max_distance`, sorted by distance (lowest to
          highest). The second column consists of the corresponding indices in `T`.
      """
      if np.any(np.isnan(Q)) or np.any(np.isinf(Q)):  # pragma: no cover
          raise ValueError("Q contains illegal values (NaN or inf)")
  
      if len(Q.shape) == 1:
          Q = np.expand_dims(Q, 0)
      if len(T.shape) == 1:
          T = np.expand_dims(T, 0)
  
      d, n = T.shape
      m = Q.shape[1]
      excl_zone = int(np.ceil(m / config.STUMPY_EXCL_ZONE_DENOM))
  
      if T_subseq_isfinite is None:
          T, T_subseq_isfinite = core.preprocess_non_normalized(T, m)
      if len(T_subseq_isfinite.shape) == 1:
          T_subseq_isfinite = np.expand_dims(T_subseq_isfinite, 0)
  
      D = np.empty((d, n - m + 1))
      for i in range(d):
          D[i, :] = core.mass_absolute(
              Q[i], T[i], T_subseq_isfinite[i], p=p
          )
      D = np.mean(D, axis=0)
  
      return core._find_matches(
          D,
          excl_zone,
          max_distance=max_distance,
          max_matches=max_matches,
          query_idx=query_idx,
          atol=atol,
      )
  
imports: import warnings
  import numpy
  from .None import config, core
label_desc: Use image node_id 3 for calling a global function with example usage: aamp_match(Q, T, T_subseq_isfinite, max_distance, max_matches, atol, query_idx, p) and returns: core