code: def create_sweep_command(command: Optional[List] = None) -> List:
      """Return sweep command, filling in environment variable macros."""
      # Start from default sweep command
      command = command or DEFAULT_SWEEP_COMMAND
      for i, chunk in enumerate(command):
          # Replace environment variable macros
          # Search a str(chunk), but allow matches to be of any (ex: int) type
          if SWEEP_COMMAND_ENV_VAR_REGEX.search(str(chunk)):
              # Replace from backwards forwards
              matches = list(
                  SWEEP_COMMAND_ENV_VAR_REGEX.finditer(chunk)
              )
              for m in matches[::-1]:
                  # Default to just leaving as is if environment variable does not exist
                  _var: str = os.environ.get(m.group(1), m.group(1))
                  command[
                      i
                  ] = f"{command[i][:m.start()]}{_var}{command[i][m.end():]}"
      return command
  
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 7 for calling a global function with example usage: create_sweep_command(command) and returns: command