code: def test_motifs_max_matches():
      # This test covers the following:
  
      # A time series contains motif A at four locations and motif B at two.
      # If `max_moitf=2` and `max_matches=3`, the result should contain
      # (at most) two sets of motifs and each motif set should contain
      # (at most) the top three matches
      T = np.array(
          [
              0.0,  # motif A
              1.0,
              0.0,
              2.3,
              -1.0,  # motif B
              -1.0,
              -2.0,
              0.0,  # motif A
              1.0,
              0.0,
              -2.0,
              -1.0,  # motif B
              -1.03,
              -2.0,
              -0.5,
              2.0,  # motif A
              3.0,
              2.04,
              2.3,
              2.0,  # motif A
              3.0,
              3.0,
          ]
      )
      m = 3
      max_motifs = 2
      max_matches = 3
  
      left_indices = [[0, 7], [4, 11]]
      left_profile_values = [
          [0.0, 0.0],
          [
              0.0,
              naive.distance(
                  core.z_norm(
                      T[left_indices[1][0] : left_indices[1][0] + m]
                  ),
                  core.z_norm(
                      T[left_indices[1][1] : left_indices[1][1] + m]
                  ),
              ),
          ],
      ]
  
      mp = naive.stump(T, m)
      right_distance_values, right_indices = motifs(
          T,
          mp[:, 0],
          max_motifs=max_motifs,
          max_matches=max_matches,
          max_distance=0.05,
          cutoff=np.inf,
      )
  
      # We ignore indices because of sorting ambiguities for equal distances.
      # As long as the distances are correct, the indices will be too.
      npt.assert_almost_equal(
          left_profile_values, right_distance_values
      )
  
imports: import functools
  import naive
  import numpy
  import numpy.testing
  import pytest
  from stumpy import core, match, motifs
label_desc: Use image node_id 6 for calling a global function with example usage: test_motifs_max_matches() without return types