code: def eval_STOI(ref, y, fs, extended=False, compute_permutation=True):
      """Calculate STOI
  
      Reference:
          A short-time objective intelligibility measure
              for time-frequency weighted noisy speech
          https://ieeexplore.ieee.org/document/5495701
  
      Note(kamo):
          STOI is defined on the signal at 10kHz
          and the input at the other sampling rate will be resampled.
          Thus, the result differs depending on the implementation of resampling.
          Especially, pystoi cannot reproduce matlab's resampling now.
  
      :param ref (np.ndarray): Reference (Nsrc, Nframe, Nmic)
      :param y (np.ndarray): Enhanced (Nsrc, Nframe, Nmic)
      :param fs (int): Sample frequency
      :param extended (bool): stoi or estoi
      :param compute_permutation (bool):
      :return: value, perm
      :rtype: Tuple[Tuple[float, ...], Tuple[int, ...]]
      """
      if ref.shape != y.shape:
          raise ValueError(
              "ref and y should have the same shape: {} != {}".format(
                  ref.shape, y.shape
              )
          )
      if ref.ndim != 3:
          raise ValueError(
              "Input must have 3 dims: {}".format_map(ref.ndim)
          )
      n_src = ref.shape[0]
      n_mic = ref.shape[2]
  
      if compute_permutation:
          index_list = list(itertools.permutations(range(n_src)))
      else:
          index_list = [list(range(n_src))]
  
      values = [
          [
              sum(
                  stoi(ref[i, :, ch], y[j, :, ch], fs, extended)
                  for ch in range(n_mic)
              )
              / n_mic
              for i, j in enumerate(indices)
          ]
          for indices in index_list
      ]
  
      best_pairs = sorted(
          [(v, i) for v, i in zip(values, index_list)],
          key=lambda x: sum(x[0]),
      )[-1]
      value, perm = best_pairs
      return tuple(value), tuple(perm)
  
imports: import argparse
  import itertools
  import logging
  import os
  import shutil
  import subprocess
  import sys
  import warnings
  from collections import OrderedDict
  from distutils.util import strtobool
  from pathlib import Path
  from tempfile import TemporaryDirectory
  import museval
  import numpy
  import soundfile
  from pystoi.stoi import stoi
  from espnet.utils.cli_utils import get_commandline_args
label_desc: Use image node_id 1 for calling a global function with example usage: eval_STOI(ref, y, fs, extended, compute_permutation) and returns: tuple,  tuple