code: def construct_scheduler_args(
      sweep_config: Dict[str, Any],
      queue: str,
      project: str,
      author: Optional[str] = None,
      return_job: bool = False,
  ) -> Union[List[str], Dict[str, str], None]:
      """Construct sweep scheduler args.
  
      logs error and returns None if misconfigured,
      otherwise returns args as a dict if is_job else a list of strings.
      """
      job = sweep_config.get("job")
      image_uri = sweep_config.get("image_uri")
      if not job and not image_uri:  # don't allow empty string
          wandb.termerror(
              "No 'job' nor 'image_uri' top-level key found in sweep config, exactly one is required for a launch-sweep"
          )
          return None
      elif job and image_uri:
          wandb.termerror(
              "Sweep config has both 'job' and 'image_uri' but a launch-sweep can use only one"
          )
          return None
  
      # if scheduler is a job, return args as dict
      if return_job:
          args_dict: Dict[str, str] = {
              "sweep_id": "WANDB_SWEEP_ID",
              "queue": queue,
              "project": project,
          }
          if job:
              args_dict["job"] = job
          elif image_uri:
              args_dict["image_uri"] = image_uri
  
          if author:
              args_dict["author"] = author
  
          return args_dict
  
      # scheduler uses cli commands, pass args as param list
      args = [
          "--queue",
          f"{queue!r}",
          "--project",
          f"{project!r}",
      ]
      if author:
          args += [
              "--author",
              f"{author!r}",
          ]
      if job:
          args += [
              "--job",
              f"{job!r}",
          ]
      elif image_uri:
          args += ["--image_uri", image_uri]
  
      return args
  
file_path: wandb/wandb/sdk/launch/sweeps/utils.py
imports: import json
  import os
  import re
  from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
  import yaml
  import wandb
  from wandb import util
  from wandb.sdk.launch.errors import LaunchError
label_desc: Use image node_id 6 for calling a global function with example usage: construct_scheduler_args(sweep_config, queue, project, author, return_job) and returns: args, None, args_dict, None