code: def music_thumbnailing(
      signal,
      sampling_rate,
      short_window=1.0,
      short_step=0.5,
      thumb_size=10.0,
      limit_1=0,
      limit_2=1,
  ):
      """
      This function detects instances of the most representative part of a
      music recording, also called "music thumbnails".
      A technique similar to the one proposed in [1], however a wider set of
      audio features is used instead of chroma features.
      In particular the following steps are followed:
       - Extract short-term audio features. Typical short-term window size: 1
         second
       - Compute the self-similarity matrix, i.e. all pairwise similarities
         between feature vectors
       - Apply a diagonal mask is as a moving average filter on the values of the
         self-similarty matrix.
         The size of the mask is equal to the desirable thumbnail length.
       - Find the position of the maximum value of the new (filtered)
         self-similarity matrix. The audio segments that correspond to the
         diagonial around that position are the selected thumbnails
  
  
      ARGUMENTS:
       - signal:            input signal
       - sampling_rate:            sampling frequency
       - short_window:     window size (in seconds)
       - short_step:    window step (in seconds)
       - thumb_size:    desider thumbnail size (in seconds)
  
      RETURNS:
       - A1:            beginning of 1st thumbnail (in seconds)
       - A2:            ending of 1st thumbnail (in seconds)
       - B1:            beginning of 2nd thumbnail (in seconds)
       - B2:            ending of 2nd thumbnail (in seconds)
  
      USAGE EXAMPLE:
         import audioFeatureExtraction as aF
       [fs, x] = basicIO.readAudioFile(input_file)
       [A1, A2, B1, B2] = musicThumbnailing(x, fs)
  
      [1] Bartsch, M. A., & Wakefield, G. H. (2005). Audio thumbnailing
      of popular music using chroma-based representations.
      Multimedia, IEEE Transactions on, 7(1), 96-104.
      """
      signal = audioBasicIO.stereo_to_mono(signal)
      # feature extraction:
      st_feats, _ = stf.feature_extraction(
          signal,
          sampling_rate,
          sampling_rate * short_window,
          sampling_rate * short_step,
      )
  
      # self-similarity matrix
      sim_matrix = self_similarity_matrix(st_feats)
  
      # moving filter:
      m_filter = int(round(thumb_size / short_step))
      diagonal = np.eye(m_filter, m_filter)
      sim_matrix = scipy.signal.convolve2d(
          sim_matrix, diagonal, "valid"
      )
  
      # post-processing (remove main diagonal elements)
      min_sm = np.min(sim_matrix)
      for i in range(sim_matrix.shape[0]):
          for j in range(sim_matrix.shape[1]):
              if abs(i - j) < 5.0 / short_step or i > j:
                  sim_matrix[i, j] = min_sm
  
      # find max position:
      sim_matrix[0 : int(limit_1 * sim_matrix.shape[0]), :] = min_sm
      sim_matrix[:, 0 : int(limit_1 * sim_matrix.shape[0])] = min_sm
      sim_matrix[int(limit_2 * sim_matrix.shape[0]) : :, :] = min_sm
      sim_matrix[:, int(limit_2 * sim_matrix.shape[0]) : :] = min_sm
  
      rows, cols = np.unravel_index(
          sim_matrix.argmax(), sim_matrix.shape
      )
      i1 = rows
      i2 = rows
      j1 = cols
      j2 = cols
  
      while i2 - i1 < m_filter:
          if (
              i1 <= 0
              or j1 <= 0
              or i2 >= sim_matrix.shape[0] - 2
              or j2 >= sim_matrix.shape[1] - 2
          ):
              break
          if sim_matrix[i1 - 1, j1 - 1] > sim_matrix[i2 + 1, j2 + 1]:
              i1 -= 1
              j1 -= 1
          else:
              i2 += 1
              j2 += 1
  
      return (
          short_step * i1,
          short_step * i2,
          short_step * j1,
          short_step * j2,
          sim_matrix,
      )
  
imports: from __future__ import print_function
  import os
  import csv
  import glob
  import scipy
  import sklearn
  import numpy
  import hmmlearn.hmm
  import sklearn.cluster
  import pickle
  import matplotlib.pyplot
  from scipy.spatial import distance
  import sklearn.discriminant_analysis
  from sklearn.preprocessing import StandardScaler
  import sys
  import pyAudioAnalysis.audioBasicIO
  import pyAudioAnalysis.audioTrainTest
  import pyAudioAnalysis.MidTermFeatures
  import pyAudioAnalysis.ShortTermFeatures
label_desc: Use image node_id 22 for calling a global function with example usage: music_thumbnailing(signal, sampling_rate, short_window, short_step, thumb_size, limit_1, limit_2) and returns: unknown,  unknown,  unknown,  unknown,  sim_matrix