code: def _aamp_motifs(
      T,
      P,
      T_subseq_isfinite,
      p,
      excl_zone,
      min_neighbors,
      max_distance,
      cutoff,
      max_matches,
      max_motifs,
      atol=1e-8,
  ):
      """
      Find the top non-normalized motifs (i.e., without z-normalization) for time series
      `T`.
  
      A subsequence, `Q`, becomes a candidate motif if there are at least `min_neighbor`
      number of other subsequence matches in `T` (outside the exclusion zone) with a
      distance less or equal to `max_distance`.
  
      Parameters
      ----------
      T : numpy.ndarray
          The time series or sequence
  
      P : numpy.ndarray
          Matrix Profile of `T`
  
      T_subseq_isfinite : numpy.ndarray
          A boolean array that indicates whether a subsequence in `T` contains a
          `np.nan`/`np.inf` value (False)
  
      p : float
          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.
  
      excl_zone : int
          Size of the exclusion zone
  
      min_neighbors : int
          The minimum number of similar matches a subsequence needs to have in order
          to be considered a motif.
  
      max_distance : float or function
          For a candidate motif, `Q`, and a non-trivial subsequence, `S`, `max_distance`
          is the maximum distance allowed between `Q` and `S` so that `S` is considered
          a match of `Q`. If `max_distance` is a function, then it must be a function
          that accepts a single parameter, `D`, in its function signature, which is the
          distance profile between `Q` and `T`.
  
      cutoff : float
          The largest matrix profile value (distance) that a candidate motif is allowed
          to have.
  
      max_matches : int
          The maximum number of similar matches to be returned. The resulting
          matches are sorted by distance (starting with the most similar). Note that the
          first match is always the self-match/trivial-match for each motif.
  
      max_motifs : int
          The maximum number of motifs to return.
  
      atol : float, default 1e-8
          The absolute tolerance parameter. This value will be added to `max_distance`
          when comparing distances between subsequences.
  
      Returns
      -------
      motif_distances : numpy.ndarray
          The distances corresponding to a set of subsequence matches for each motif.
          Note that the first column always corresponds to the distance for the
          self-match/trivial-match for each motif.
  
      motif_indices : numpy.ndarray
          The indices corresponding to a set of subsequences matches for each motif
          Note that the first column always corresponds to the index for the
          self-match/trivial-match for each motif
      """
      n = T.shape[1]
      l = P.shape[1]
      m = n - l + 1
  
      motif_indices = []
      motif_distances = []
  
      candidate_idx = np.argmin(P[-1])
      for _ in range(l):
          if len(motif_indices) >= max_motifs:
              break
  
          profile_value = P[-1, candidate_idx]
          if profile_value > cutoff or not np.isfinite(
              profile_value
          ):  # pragma: no cover
              break
  
          # If max_distance is a constant (independent of the distance profile D of Q
          # and T), then we can stop the iteration if the matrix profile value of Q is
          # larger than the maximum distance.
          if (
              isinstance(max_distance, float)
              and profile_value > max_distance
          ):  # pragma: no cover
              break
  
          Q = T[:, candidate_idx : candidate_idx + m]
  
          query_matches = aamp_match(
              Q,
              T,
              max_matches=None,
              max_distance=max_distance,
              atol=atol,
              query_idx=candidate_idx,
              p=p,
          )
  
          if len(query_matches) > min_neighbors:
              motif_distances.append(query_matches[:max_matches, 0])
              motif_indices.append(query_matches[:max_matches, 1])
  
          if len(query_matches) == 0:  # pragma: no cover
              query_matches = np.array([[np.nan, candidate_idx]])
  
          for idx in query_matches[:, 1]:
              core.apply_exclusion_zone(P, int(idx), excl_zone, np.inf)
  
          candidate_idx = np.argmin(P[-1])
  
      motif_distances = core._jagged_list_to_array(
          motif_distances, fill_value=np.nan, dtype=np.float64
      )
      motif_indices = core._jagged_list_to_array(
          motif_indices, fill_value=-1, dtype=np.int64
      )
  
      return motif_distances, motif_indices
  
imports: import warnings
  import numpy
  from .None import config, core
label_desc: Use image node_id 1 for calling a global function with example usage: _aamp_motifs(T, P, T_subseq_isfinite, p, excl_zone, min_neighbors, max_distance, cutoff, max_matches, max_motifs, atol) and returns: motif_distances,  motif_indices