code: def main():
      parser = get_parser()
      args = parser.parse_args()
  
      print(f"data path: {args.feats_scp}")
      os.makedirs(args.save_dir, exist_ok=True)
  
      x = []
      length_file = f"{args.save_dir}/{args.split}.lengths"
  
      with open(args.feats_scp, "r") as f_scp, open(
          length_file, "w"
      ) as lf:
          for line in f_scp.readlines():
              utt_id, feats_path = line.split()
              feats = np.load(feats_path)
              x.append(feats)
              lf.write(f"{utt_id} {feats.shape[0]}\n")
  
      features = np.vstack(x)
  
      pca_A = torch.from_numpy(np.load(args.pca_path + "_A.npy")).cuda()
      pca_b = torch.from_numpy(np.load(args.pca_path + "_b.npy")).cuda()
  
      save_path = osp.join(args.save_dir, args.split)
  
      npaa = NpyAppendArray(save_path + ".npy")
  
      batches = math.ceil(features.shape[0] / args.batch_size)
  
      with torch.no_grad():
          for b in tqdm.trange(batches):
              start = b * args.batch_size
              end = start + args.batch_size
              x = torch.from_numpy(features[start:end]).cuda()
              x = torch.matmul(x, pca_A) + pca_b
              npaa.append(x.cpu().numpy())
  
file_path: espnet/egs2/acesinger/svs1/pyscripts/feats/apply_pca.py
imports: import argparse
  import math
  import os
  import os.path
  from shutil import copyfile
  import numpy
  import torch
  import tqdm
  from npy_append_array import NpyAppendArray
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types