code: def main(cmd=None):
      print(get_commandline_args(), file=sys.stderr)
      parser = get_parser()
      args = parser.parse_args(cmd)
  
      # "distributed" is decided using the other command args
      resolve_distributed_mode(args)
      if not args.distributed or not args.multiprocessing_distributed:
          extract_embed(args)
  
      else:
          assert args.ngpu > 1, args.ngpu
          # Multi-processing distributed mode: e.g. 2node-4process-4GPU
          # |   Host1     |    Host2    |
          # |   Process1  |   Process2  |  <= Spawn processes
          # |Child1|Child2|Child1|Child2|
          # |GPU1  |GPU2  |GPU1  |GPU2  |
  
          # See also the following usage of --multiprocessing-distributed:
          # https://github.com/pytorch/examples/blob/master/imagenet/main.py
          num_nodes = get_num_nodes(
              args.dist_world_size, args.dist_launcher
          )
          if num_nodes == 1:
              args.dist_master_addr = "localhost"
              args.dist_rank = 0
              # Single node distributed training with multi-GPUs
              if (
                  args.dist_init_method == "env://"
                  and get_master_port(args.dist_master_port) is None
              ):
                  # Get the unused port
                  args.dist_master_port = free_port()
  
          # Assume that nodes use same number of GPUs each other
          args.dist_world_size = args.ngpu * num_nodes
          node_rank = get_node_rank(args.dist_rank, args.dist_launcher)
  
          # The following block is copied from:
          # https://github.com/pytorch/pytorch/blob/master/torch/multiprocessing/spawn.py
          error_queues = []
          processes = []
          mp = torch.multiprocessing.get_context("spawn")
          for i in range(args.ngpu):
              # Copy args
              local_args = argparse.Namespace(**vars(args))
  
              local_args.local_rank = i
              local_args.dist_rank = args.ngpu * node_rank + i
              local_args.ngpu = 1
  
              process = mp.Process(
                  target=extract_embed,
                  args=(local_args,),
                  daemon=False,
              )
              process.start()
              processes.append(process)
              error_queues.append(mp.SimpleQueue())
          # Loop on join until it returns True or raises an exception.
          while not ProcessContext(processes, error_queues).join():
              pass
  
imports: import argparse
  import logging
  import os
  import sys
  from glob import glob
  import humanfriendly
  import numpy
  import torch
  from torch.multiprocessing.spawn import ProcessContext
  from typeguard import check_argument_types, check_return_type
  from espnet2.samplers.build_batch_sampler import BATCH_TYPES
  from espnet2.tasks.spk import SpeakerTask
  from espnet2.torch_utils.set_all_random_seed import set_all_random_seed
  from espnet2.train.distributed_utils import DistributedOption, free_port, get_master_port, get_node_rank, get_num_nodes, resolve_distributed_mode
  from espnet2.train.reporter import Reporter, SubReporter
  from espnet2.utils import config_argparse
  from espnet2.utils.build_dataclass import build_dataclass
  from espnet2.utils.nested_dict_action import NestedDictAction
  from espnet2.utils.types import humanfriendly_parse_size_or_none, int_or_none, str2bool, str2triple_str, str_or_none
  from espnet.utils.cli_utils import get_commandline_args
label_desc: Use image node_id 3 for calling a global function with example usage: main(cmd) without return types