code: def calculate(
      file_list: List[str],
      predictor: torch.nn.Module,
      device: torch.device,
      batchsize: int,
  ):
      """Calculate pseudo MOS."""
      pmos_dict = {}
      fs = librosa.get_samplerate(file_list[0])
      for si, _ in enumerate(file_list[::batchsize]):
          gen_paths = []
          gen_xs = []
          for bi in range(batchsize):
              if si * batchsize + bi >= len(file_list):
                  break
              gen_path = file_list[si * batchsize + bi]
              gen_paths.append(gen_path)
              gen_x, gen_fs = librosa.load(gen_path, sr=None, mono=True)
              # Assuming same sampling rate for all files.
              assert fs == gen_fs
              gen_xs.append(gen_x)
          # Padding
          max_len = max([len(gen_x) for gen_x in gen_xs])
          for bi in range(batchsize):
              if si * batchsize + bi >= len(file_list):
                  break
              gen_xs[bi] = np.pad(
                  gen_xs[bi],
                  (0, max_len - len(gen_xs[bi])),
                  "constant",
                  constant_values=0,
              )
          gen_xs = torch.from_numpy(np.stack(gen_xs)).to(device)
          # Compute pseudo MOS.
          scores = predictor(gen_xs, fs)
          for gen_path, score in zip(gen_paths, scores):
              gen_basename = _get_basename(gen_path)
              pmos = score.item()
              logging.info(f"{gen_basename} {pmos:.4f}")
              pmos_dict[gen_basename] = pmos
      return pmos_dict
  
file_path: espnet/egs2/chime2/enh1/pyscripts/utils/evaluate_pseudomos.py
imports: import argparse
  import fnmatch
  import logging
  import os
  from typing import List
  import librosa
  import numpy
  import torch
label_desc: Use image node_id 3 for calling a global function with example usage: calculate(file_list, predictor, device, batchsize) and returns: pmos_dict