code: def group_operations(operation_list):
      """
      Group operations to efficiently perform them.
      E.g. group multiple segment operations from the same file.
      Output operation examples:
      - ('copy', ('src_file','tgt_file'))
      - ('segment', ('src_file', [('seg_1', 'tgt_file_1'),..., ('seg_N', 'tgt_file_N')]))
      """
  
      # only need to group segment operations for now
      # Dict of src file as key, so that segment operations
      # for one src file are performed at one time
      grouped_segment_operations = defaultdict(list)
  
      grouped_operation_list = []
      for op, items in operation_list:
          if op == "segment":
              src_file, seg, tgt_file = items
              grouped_segment_operations[src_file].append(
                  (seg, tgt_file)
              )
          else:
              grouped_operation_list.append((op, items))
  
      for src_file, tgt_segments in grouped_segment_operations.items():
          grouped_operation_list.append(
              ("segment", (src_file, tgt_segments))
          )
  
      print(f"Grouped to {len(grouped_operation_list)} operations")
  
      return grouped_operation_list
  
file_path: textlesslib/examples/expresso/dataset/processing/perform_operations.py
imports: import os
  import shutil
  from pathlib import Path
  from collections import defaultdict
  import scipy.io.wavfile
  from multiprocessing import Pool
  from tqdm import tqdm
  from time import time
label_desc: Use image node_id 2 for calling a global function with example usage: group_operations(operation_list) and returns: grouped_operation_list