code: def _mstump(
      T,
      m,
      range_stop,
      excl_zone,
      M_T,
      Σ_T,
      QT,
      QT_first,
      μ_Q,
      σ_Q,
      T_subseq_isconstant,
      Q_subseq_isconstant,
      k,
      range_start=1,
      include=None,
      discords=False,
  ):
      """
      A Numba JIT-compiled version of mSTOMP, a variant of mSTAMP, for parallel
      computation of the multi-dimensional matrix profile and multi-dimensional
      matrix profile indices. Note that only self-joins are supported.
  
      Parameters
      ----------
      T : numpy.ndarray
          The time series or sequence for which to compute the multi-dimensional
          matrix profile
  
      m : int
          Window size
  
      range_stop : int
          The index value along T for which to stop the matrix profile
          calculation. This parameter is here for consistency with the
          distributed `mstumped` algorithm.
  
      excl_zone : int
          The half width for the exclusion zone relative to the current
          sliding window
  
      M_T : numpy.ndarray
          Sliding mean of time series, `T`
  
      Σ_T : numpy.ndarray
          Sliding standard deviation of time series, `T`
  
      QT : numpy.ndarray
          Dot product between some query sequence,`Q`, and time series, `T`
  
      QT_first : numpy.ndarray
          QT for the first window relative to the current sliding window
  
      μ_Q : numpy.ndarray
          Mean of the query sequence, `Q`, relative to the current sliding window
  
      σ_Q : numpy.ndarray
          Standard deviation of the query sequence, `Q`, relative to the current
          sliding window
  
      T_subseq_isconstant : numpy.ndarray
          A boolean array that indicates whether a subsequence in `T`
          is constant (True)
  
      Q_subseq_isconstant : numpy.ndarray
          A boolean array that indicates whether the query subsequence in `Q`
          is constant (True)
  
      k : int
          The total number of sliding windows to iterate over
  
      range_start : int, default 1
          The starting index value along T_B for which to start the matrix
          profile calculation. Default is 1.
  
      include : numpy.ndarray, default None
          A list of (zero-based) indices corresponding to the dimensions in `T` that
          must be included in the constrained multidimensional motif search.
          For more information, see Section IV D in:
  
          `DOI: 10.1109/ICDM.2017.66 \
          <https://www.cs.ucr.edu/~eamonn/Motif_Discovery_ICDM.pdf>`__
  
      discords : bool, default False
          When set to `True`, this reverses the distance profile to favor discords rather
          than motifs. Note that indices in `include` are still maintained and respected.
  
      Returns
      -------
      P : numpy.ndarray
          The multi-dimensional matrix profile. Each row of the array corresponds
          to each matrix profile for a given dimension (i.e., the first row is the
          1-D matrix profile and the second row is the 2-D matrix profile).
  
      I : numpy.ndarray
          The multi-dimensional matrix profile index where each row of the array
          corresponds to each matrix profile index for a given dimension.
  
      Notes
      -----
      `DOI: 10.1109/ICDM.2017.66 \
      <https://www.cs.ucr.edu/~eamonn/Motif_Discovery_ICDM.pdf>`__
  
      See mSTAMP Algorithm
      """
      QT_odd = QT.copy()
      QT_even = QT.copy()
      d = T.shape[0]
  
      P = np.empty((d, range_stop - range_start), dtype=np.float64)
      I = np.empty((d, range_stop - range_start), dtype=np.int64)
      D = np.empty((d, k), dtype=np.float64)
      D_prime = np.empty(k, dtype=np.float64)
      start_row_idx = 0
  
      if include is not None:
          tmp_swap = np.empty((include.shape[0], k), dtype=np.float64)
          restricted_indices = include[include < include.shape[0]]
          unrestricted_indices = include[include >= include.shape[0]]
          mask = np.ones(include.shape[0], dtype=bool)
          mask[restricted_indices] = False
  
      for idx in range(range_start, range_stop):
          _compute_multi_D(
              d,
              k,
              idx,
              D,
              T,
              m,
              excl_zone,
              M_T,
              Σ_T,
              QT_even,
              QT_odd,
              QT_first,
              μ_Q,
              σ_Q,
              Q_subseq_isconstant,
              T_subseq_isconstant,
          )
  
          # `include` processing must occur here since we are dealing with distances
          if include is not None:
              core._apply_include(
                  D,
                  include,
                  restricted_indices,
                  unrestricted_indices,
                  mask,
                  tmp_swap,
              )
              start_row_idx = include.shape[0]
  
          if discords:
              D[start_row_idx:][::-1].sort(axis=0)
          else:
              D[start_row_idx:].sort(axis=0)
  
          core._compute_multi_PI(d, idx, D, D_prime, range_start, P, I)
  
      return P, I
  
file_path: stumpy/stumpy/mstump.py
imports: from functools import lru_cache, partial
  import numpy
  from numba import njit, prange
  from scipy.stats import norm
  from .None import config, core
  from .maamp import maamp, maamp_mdl, maamp_multi_distance_profile, maamp_subspace
label_desc: Use image node_id 11 for calling a global function with example usage: _mstump(T, m, range_stop, excl_zone, M_T, Σ_T, QT, QT_first, μ_Q, σ_Q, T_subseq_isconstant, Q_subseq_isconstant, k, range_start, include, discords) and returns: P,  I