code: def _popen_args(
      opspec=None,
      flags=None,
      label=None,
      tags=None,
      comment=None,
      run_dir=None,
      restart=None,
      start=None,
      stage=None,
      proto=None,
      force_sourcecode=False,
      batch_files=None,
      batch_label=None,
      batch_tags=None,
      batch_comment=None,
      extra_env=None,
      optimize=False,
      optimizer=None,
      minimize=None,
      maximize=None,
      opt_flags=None,
      max_trials=None,
      random_seed=None,
      debug_sourcecode=None,
      needed=False,
      stage_trials=False,
      force_flags=False,
      force_deps=False,
      stop_after=None,
      fail_on_trial_error=False,
      print_cmd=False,
      print_trials=False,
      save_trials=None,
      guild_home=None,
      cwd=None,
      quiet=False,
      debug=False,
      test_sourcecode=False,
      gpus=None,
      help_op=False,
      run_id=None,
      background=False,
      keep_run=False,
      keep_batch=False,
      deps=None,
  ):
      from guild import op_util
  
      cwd = cwd or "."
      flags = flags or {}
      opt_flags = opt_flags or {}
      tags = tags or []
      batch_tags = batch_tags or []
      args = [sys.executable, "-um", "guild.main_bootstrap"]
      if debug:
          args.append("--debug")
      args.extend(["run", "-y"])
      if opspec:
          args.append(opspec)
      if restart:
          args.extend(["--restart", restart])
      # start is a synonym for restart - pass this through as provided.
      if start:
          args.extend(["--start", start])
      if stage:
          args.append("--stage")
      if proto:
          args.extend(["--proto", proto])
      if force_sourcecode:
          args.append("--force-sourcecode")
      if label:
          args.extend(["--label", label])
      for tag in tags:
          args.extend(["--tag", tag])
      if comment:
          args.extend(["--comment", comment])
      if batch_label:
          args.extend(["--batch-label", batch_label])
      for tag in batch_tags:
          args.extend(["--batch-tag", tag])
      if batch_comment:
          args.extend(["--batch-comment", batch_comment])
      if run_dir:
          args.extend(["--run-dir", run_dir])
      if optimize:
          args.append("--optimize")
      if optimizer:
          args.extend(["--optimizer", optimizer])
      if minimize:
          args.extend(["--minimize", minimize])
      if maximize:
          args.extend(["--maximize", maximize])
      for name, val in sorted(opt_flags.items()):
          args.extend(["--opt-flag", op_util.flag_assign(name, val)])
      if max_trials is not None:
          args.extend(["--max-trials", str(max_trials)])
      if random_seed is not None:
          args.extend(["--random-seed", str(random_seed)])
      if debug_sourcecode:
          args.extend(["--debug-sourcecode", debug_sourcecode])
      if needed:
          args.append("--needed")
      if print_cmd:
          args.append("--print-cmd")
      if print_trials:
          args.append("--print-trials")
      if save_trials:
          args.extend(["--save-trials", save_trials])
      if stage_trials:
          args.append("--stage-trials")
      if force_flags:
          args.append("--force-flags")
      if force_deps:
          args.append("--force-deps")
      if stop_after is not None:
          args.extend(["--stop-after", str(stop_after)])
      if fail_on_trial_error:
          args.append("--fail-on-trial-error")
      if quiet:
          args.append("--quiet")
      if test_sourcecode:
          args.append("--test-sourcecode")
      if gpus:
          args.extend(["--gpus", str(gpus)])
      if help_op:
          args.append("--help-op")
      if run_id:
          args.extend(["--run-id", run_id])
      if background:
          args.append("--background")
      if keep_run:
          args.append("--keep-run")
      if keep_batch:
          args.append("--keep-batch")
      deps = deps or []
      for dep in deps:
          args.extend(["--dep", dep])
      args.extend(op_util.flag_assigns(flags))
      args.extend([f"@{path}" for path in (batch_files or [])])
      env = dict(os.environ)
      env["NO_IMPORT_FLAGS_PROGRESS"] = "1"
      if extra_env:
          env.update(extra_env)
      _apply_guild_home_env(env, guild_home)
      _apply_python_path_env(env)
      _apply_lang_env(env)
      return args, cwd, env
  
imports: import os
  import subprocess
  import sys
label_desc: Use image node_id 4 for calling a global function with example usage: _popen_args(opspec, flags, label, tags, comment, run_dir, restart, start, stage, proto, force_sourcecode, batch_files, batch_label, batch_tags, batch_comment, extra_env, optimize, optimizer, minimize, maximize, opt_flags, max_trials, random_seed, debug_sourcecode, needed, stage_trials, force_flags, force_deps, stop_after, fail_on_trial_error, print_cmd, print_trials, save_trials, guild_home, cwd, quiet, debug, test_sourcecode, gpus, help_op, run_id, background, keep_run, keep_batch, deps) and returns: args,  cwd,  env