code: def split_scps(
      scps: List[str],
      num_splits: int,
      names: Optional[List[str]],
      output_dir: str,
      log_level: str,
  ):
      logging.basicConfig(
          level=log_level,
          format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s",
      )
      if num_splits < 2:
          raise RuntimeError(f"{num_splits} must be more than 1")
  
      if names is None:
          names = [Path(s).name for s in scps]
          if len(set(names)) != len(names):
              raise RuntimeError(f"names are duplicated: {names}")
  
      for name in names:
          (Path(output_dir) / name).mkdir(parents=True, exist_ok=True)
  
      scp_files = [open(s, "r", encoding="utf-8") for s in scps]
  
      # Create output files in 'w' mode to overwrite existing files if any
      out_files = {
          name: {
              num: (Path(output_dir) / name / f"split.{num}").open(
                  "w", encoding="utf-8"
              )
              for num in range(num_splits)
          }
          for name in names
      }
  
      counter = Counter()
      linenum = -1
      for linenum, lines in enumerate(zip_longest(*scp_files)):
          if any(line is None for line in lines):
              raise RuntimeError("Number of lines are mismatched")
  
          prev_key = None
          for line in lines:
              key = line.rstrip().split(maxsplit=1)[0]
              if prev_key is not None and prev_key != key:
                  raise RuntimeError(
                      "Not sorted or not having same keys"
                  )
              prev_key = key
  
          # Select a piece from split texts alternatively
          num = linenum % num_splits
          counter[num] += 1
          # Write lines respectively
          for line, name in zip(lines, names):
              out_files[name][num].write(line)
  
      if linenum + 1 < num_splits:
          raise RuntimeError(
              f"The number of lines is less than num_splits: {linenum + 1} < {num_splits}"
          )
  
      for name in names:
          with (Path(output_dir) / name / "num_splits").open(
              "w", encoding="utf-8"
          ) as f:
              f.write(str(num_splits))
      logging.info(f"N lines of split text: {set(counter.values())}")
  
file_path: espnet/espnet2/bin/split_scps.py
imports: import argparse
  import logging
  import sys
  from collections import Counter
  from itertools import zip_longest
  from pathlib import Path
  from typing import List, Optional
  from espnet.utils.cli_utils import get_commandline_args
label_desc: Use image node_id 1 for calling a global function with example usage: split_scps(scps, num_splits, names, output_dir, log_level) without return types