code: def _matrixProfile_sampling(
      tsA,
      m,
      orderClass,
      distanceProfileFunction,
      tsB=None,
      sampling=0.2,
      random_state=None,
  ):
      order = orderClass(len(tsA) - m + 1, random_state=random_state)
      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)
  
      idx = order.next()
  
      # Define max numbers of iterations to sample
      iters = (len(tsA) - m + 1) * sampling
  
      iter_val = 0
  
      while iter_val < iters:
          (distanceProfile, querySegmentsID) = distanceProfileFunction(
              tsA, idx, m, tsB
          )
  
          # Check which of the indices have found a new minimum
          idsToUpdate = distanceProfile < 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, distanceProfile)
          idx = order.next()
  
          iter_val += 1
      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 7 for calling a global function with example usage: _matrixProfile_sampling(tsA, m, orderClass, distanceProfileFunction, tsB, sampling, random_state) and returns: mp,  mpIndex