code: def train_hmm_compute_statistics(features, labels):
      """
      This function computes the statistics used to train
      an HMM joint segmentation-classification model
      using a sequence of sequential features and respective labels
  
      ARGUMENTS:
       - features:  a np matrix of feature vectors (numOfDimensions x n_wins)
       - labels:    a np array of class indices (n_wins x 1)
      RETURNS:
       - class_priors:            matrix of prior class probabilities
                                  (n_classes x 1)
       - transmutation_matrix:    transition matrix (n_classes x n_classes)
       - means:                   means matrix (numOfDimensions x 1)
       - cov:                     deviation matrix (numOfDimensions x 1)
      """
      unique_labels = np.unique(labels)
      n_comps = len(unique_labels)
  
      n_feats = features.shape[0]
  
      if features.shape[1] < labels.shape[0]:
          print(
              "trainHMM warning: number of short-term feature vectors "
              "must be greater or equal to the labels length!"
          )
          labels = labels[0 : features.shape[1]]
  
      # compute prior probabilities:
      class_priors = np.zeros((n_comps,))
      for i, u_label in enumerate(unique_labels):
          class_priors[i] = np.count_nonzero(labels == u_label)
      # normalize prior probabilities
      class_priors = class_priors / class_priors.sum()
  
      # compute transition matrix:
      transmutation_matrix = np.zeros((n_comps, n_comps))
      for i in range(labels.shape[0] - 1):
          transmutation_matrix[int(labels[i]), int(labels[i + 1])] += 1
      # normalize rows of transition matrix:
      for i in range(n_comps):
          transmutation_matrix[i, :] /= transmutation_matrix[i, :].sum()
  
      means = np.zeros((n_comps, n_feats))
      for i in range(n_comps):
          means[i, :] = np.array(
              features[
                  :, np.nonzero(labels == unique_labels[i])[0]
              ].mean(axis=1)
          )
  
      cov = np.zeros((n_comps, n_feats))
      for i in range(n_comps):
          """
          cov[i, :, :] = np.cov(features[:, np.nonzero(labels == u_labels[i])[0]])
          """
          # use line above if HMM using full gaussian distributions are to be used
          cov[i, :] = np.std(
              features[:, np.nonzero(labels == unique_labels[i])[0]],
              axis=1,
          )
  
      return class_priors, transmutation_matrix, means, cov
  
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 9 for calling a global function with example usage: train_hmm_compute_statistics(features, labels) and returns: class_priors,  transmutation_matrix,  means,  cov