code: def main(get_grid, postprocess_hyperparams, args):
      if args.local:
          args.num_nodes = 1
  
      # compute all possible hyperparameter configurations
      grid = get_grid(args)
      grid_product = list(
          itertools.product(*[hp.values for hp in grid])
      )
  
      # randomly shuffle configurations
      random.seed(args.seed)
      random.shuffle(grid_product)
  
      for i, hp_values in enumerate(grid_product):
          config = OrderedDict()
          for hp, value in zip(grid, hp_values):
              config[hp.name] = hp
              config[hp.name].current_value = value
  
          # postprocess hyperparams
          postprocess_hyperparams(args, config)
  
          # launch training
          job_id = launch_train(args, config)
          if job_id is not None:
              print(f"Launched {job_id}")
  
          if args.sequential and not args.local and job_id is not None:
              args.dep = job_id
  
          if i == args.num_trials - 1:
              break
  
file_path: mmf/tools/sweeps/lib/slurm.py
imports: import datetime
  import itertools
  import os
  import random
  import shlex
  import shutil
  import subprocess
  from collections import OrderedDict
  from glob import glob
  from mmf.utils.general import get_mmf_root
label_desc: Use image node_id 1 for calling a global function with example usage: main(get_grid, postprocess_hyperparams, args) without return types