code: def _SB_TransitionMatrix_3ac_sumdiagcov(X, acfz):
      # Trace of covariance of transition matrix between symbols in 3-letter
      # alphabet.
      ds = np.zeros(int((len(X) - 1) / acfz + 1))
      for i in range(len(ds)):
          ds[i] = X[i * acfz]
      indices = np.argsort(ds)
  
      bins = np.zeros(len(ds), dtype=np.int32)
      q1 = int(len(ds) / 3)
      q2 = q1 * 2
      for i in range(q1 + 1, q2 + 1):
          bins[indices[i]] = 1
      for i in range(q2 + 1, len(indices)):
          bins[indices[i]] = 2
  
      t = np.zeros((3, 3))
      for i in range(len(ds) - 1):
          t[bins[i + 1]][bins[i]] += 1
      t /= len(ds) - 1
  
      means = np.zeros(3)
      for i in range(3):
          means[i] = np.mean(t[i])
  
      cov = np.zeros((3, 3))
      for i in range(3):
          for n in range(3):
              covariance = 0
              for j in range(3):
                  covariance += (t[i][j] - means[i]) * (
                      t[n][j] - means[n]
                  )
              covariance /= 2
  
              cov[i][n] = covariance
              cov[n][i] = covariance
  
      ssum = 0
      for i in range(3):
          ssum += cov[i][i]
  
      return ssum
  
imports: import math
  import numpy
  from sktime.utils.numba.njit import njit
label_desc: Use image node_id 35 for calling a global function with example usage: _SB_TransitionMatrix_3ac_sumdiagcov(X, acfz) and returns: ssum