code: def aamp_motifs(
      T,
      P,
      min_neighbors=1,
      max_distance=None,
      cutoff=None,
      max_matches=10,
      max_motifs=1,
      atol=1e-8,
      p=2.0,
  ):
      """
      Discover 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`.
  
      Note that, in the best case scenario, the returned arrays would have shape
      `(max_motifs, max_matches)` and contain all finite values. However, in reality,
      many conditions (see below) need to be satisfied in order for this to be true. Any
      truncation in the number of rows (i.e., motifs)  may be the result of insufficient
      candidate motifs with matches greater than or equal to `min_neighbors` or that the
      matrix profile value for the candidate motif was larger than `cutoff`. Similarly,
      any truncation in the number of columns (i.e., matches) may be the result of
      insufficient matches being found with distances (to their corresponding candidate
      motif) that are equal to or less than `max_distance`. Only motifs and matches that
      satisfy all of these constraints will be returned.
  
      If you must return a shape of `(max_motifs, max_matches)`, then you may consider
      specifying a smaller `min_neighbors`, a larger `max_distance`, and/or a larger
      `cutoff`. For example, while it is ill advised, setting `min_neighbors=1`,
      `max_distance=np.inf`, and `cutoff=np.inf` will ensure that the shape of the output
      arrays will be `(max_motifs, max_matches)`. However, given the lack of constraints,
      the quality of each motif and the quality of each match may be drastically
      different. Setting appropriate conditions will help ensure appropriately
      constrained results that may be easier to interpret.
  
      Parameters
      ----------
      T : numpy.ndarray
              The time series or sequence
  
      P : numpy.ndarray
          Matrix Profile of `T`
  
      min_neighbors : int, default 1
          The minimum number of similar matches a subsequence needs to have in order
          to be considered a motif. This defaults to `1`, which means that a
          subsequence must have at least one similar match in order to be considered
          a motif.
  
      max_distance : float or function, default None
          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`. If None, this
          defaults to `np.nanmax([np.nanmean(D) - 2.0 * np.nanstd(D), np.nanmin(D)])`.
  
      cutoff : float, default None
          The largest matrix profile value (distance) that a candidate motif is
          allowed to have. If `None`, this defaults to
          `np.nanmax([np.nanmean(P) - 2.0 * np.nanstd(P), np.nanmin(P)])`
  
      max_matches : int, default 10
          The maximum amount of similar matches of a motif representative to be
          returned. The resulting matches are sorted by distance, so a value of `10`
          means that the indices of the most similar `10` subsequences is returned.
          If `None`, all matches within `max_distance` of the motif representative
          will be returned. Note that the first match is always the
          self-match/trivial-match for each motif.
  
      max_motifs : int, default 1
          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.
  
      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
      -------
      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.
  
      """
      if max_motifs < 1:  # pragma: no cover
          msg = "The maximum number of motifs, `max_motifs`, "
          msg += "must be greater than or equal to 1.\n"
          msg += "`max_motifs` has been set to `1`"
          warnings.warn(msg)
          max_motifs = 1
  
      if T.ndim != 1:  # pragma: no cover
          raise ValueError(
              f"T is {T.ndim}-dimensional and must be 1-dimensional. "
              "Multidimensional motif discovery is not yet supported."
          )
  
      if P.ndim != 1:  # pragma: no cover
          raise ValueError(
              f"P is {P.ndim}-dimensional and must be 1-dimensional. "
              "Multidimensional motif discovery is not yet supported."
          )
  
      m = T.shape[-1] - P.shape[-1] + 1
      excl_zone = int(np.ceil(m / config.STUMPY_EXCL_ZONE_DENOM))
      if max_matches is None:  # pragma: no cover
          max_matches = np.inf
      if cutoff is None:  # pragma: no cover
          P_copy = P.copy().astype(np.float64)
          P_copy[np.isinf(P_copy)] = np.nan
          cutoff = np.nanmax(
              [
                  np.nanmean(P_copy) - 2.0 * np.nanstd(P_copy),
                  np.nanmin(P_copy),
              ]
          )
  
      if cutoff == 0.0:  # pragma: no cover
          suggested_cutoff = np.partition(P, 1)[1]
          msg = "The `cutoff` has been set to 0.0 and may result in little/no candidate "
          msg += "motifs being identified.\n"
          msg += "You may consider relaxing the constraint by increasing the `cutoff` "
          msg += f"(e.g., cutoff={suggested_cutoff})."
          warnings.warn(msg)
  
      T, T_subseq_isfinite = core.preprocess_non_normalized(
          np.expand_dims(T, 0), m
      )
      P = np.expand_dims(P, 0).astype(np.float64)
  
      motif_distances, motif_indices = _aamp_motifs(
          T,
          P,
          T_subseq_isfinite,
          p,
          excl_zone,
          min_neighbors,
          max_distance,
          cutoff,
          max_matches,
          max_motifs,
          atol=atol,
      )
  
      if motif_distances.shape[1] == 0:  # pragma: no cover
          msg = "No motifs were found. You may consider increasing the `cutoff` "
          msg += f"(e.g., cutoff={2. * cutoff}) and/or increasing the `max_distance `"
          msg += "(e.g., max_distance=np.inf)."
          warnings.warn(msg)
  
      return motif_distances, motif_indices
  
imports: import warnings
  import numpy
  from .None import config, core
label_desc: Use image node_id 2 for calling a global function with example usage: aamp_motifs(T, P, min_neighbors, max_distance, cutoff, max_matches, max_motifs, atol, p) and returns: motif_distances,  motif_indices