code: def _trafo_diag(fun):
      """Obtain a function which returns the diagonal from one that returns a matrix."""
  
      def diag(X):
          mat = fun(X)
          return np.diag(mat)
  
      return diag
  
file_path: sktime/sktime/dists_kernels/dist_to_kern.py
imports: import numpy
  from sktime.dists_kernels.base import BasePairwiseTransformerPanel
label_desc: Use image node_id 1 for calling a global function with example usage: _trafo_diag(fun) and returns: diag, np