code: def _stamp_parallel(
      tsA, m, tsB=None, sampling=0.2, n_threads=-1, random_state=None
  ):
      """
      Computes distance profiles in parallel using all CPU cores by default.
  
      Parameters
      ----------
      tsA: Time series containing the queries for which to calculate the Matrix Profile.
      m: Length of subsequence to compare.
      tsB: Time series to compare the query against. Note that, if no value is provided, tsB = tsA by default.
      sampling: The percentage of all possible distance profiles to sample for the final Matrix Profile. 0 to 1
      n_threads: Number of threads to use in parallel mode. Defaults to using all CPU cores.
      random_state: Set the random seed generator for reproducible results.
      """
      if n_threads is -1:
          n_threads = multiprocessing.cpu_count()
  
      n = len(tsA)
      mp, mpIndex = _self_join_or_not_preprocess(tsA, tsB, m)
  
      if not is_array_like(tsB):
          tsB = tsA
  
      tsA = _clean_nan_inf(tsA)
      tsB = _clean_nan_inf(tsB)
  
      # determine sampling size
      sample_size = math.ceil((n - m + 1) * sampling)
  
      # generate indices to sample and split based on n_threads
      if random_state is not None:
          np.random.seed(random_state)
  
      indices = np.arange(n - m + 1)
      indices = np.random.choice(
          indices, size=sample_size, replace=False
      )
      indices = np.array_split(indices, n_threads)
  
      # create pool of workers and compute
      with multiprocessing.Pool(processes=n_threads) as pool:
          func = partial(
              distanceProfile.mass_distance_profile_parallel,
              tsA=tsA,
              tsB=tsB,
              m=m,
          )
          results = pool.map(func, indices)
  
      # The overall matrix profile is the element-wise minimum of each sub-profile, and each element of the overall
      # matrix profile index is the time series position of the corresponding sub-profile.
      for result in results:
          for dp, querySegmentsID in result:
              # Check which of the indices have found a new minimum
              idsToUpdate = dp < mp
  
              # Update the Matrix Profile Index to indicate that the current index is the minimum location for the aforementioned indices
              mpIndex[idsToUpdate] = querySegmentsID[idsToUpdate]
  
              # Update the matrix profile to include the new minimum values (where appropriate)
              mp = np.minimum(mp, dp)
  
      return (mp, mpIndex)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from .None import distanceProfile
  from .None import order
  from .utils import mass, movmeanstd
  import numpy
  import multiprocessing
  from functools import partial
  import math
  from .scrimp import scrimp_plus_plus
label_desc: Use image node_id 6 for calling a global function with example usage: _stamp_parallel(tsA, m, tsB, sampling, n_threads, random_state) and returns: mp,  mpIndex