code: def prepare_kwargs(stage, run_env=None):
      from dvc.env import DVC_ROOT
  
      kwargs = {
          "cwd": stage.wdir,
          "env": fix_env(None),
          "close_fds": True,
      }
  
      if run_env:
          kwargs["env"].update(run_env)
      if DVC_ROOT not in kwargs["env"]:
          kwargs["env"][DVC_ROOT] = stage.repo.root_dir
  
      # NOTE: when you specify `shell=True`, `Popen` [1] will default to
      # `/bin/sh` on *nix and will add ["/bin/sh", "-c"] to your command.
      # But we actually want to run the same shell that we are running
      # from right now, which is usually determined by the `SHELL` env
      # var. So instead, we compose our command on our own, making sure
      # to include special flags to prevent shell from reading any
      # configs and modifying env, which may change the behavior or the
      # command we are running. See [2] for more info.
      #
      # [1] https://github.com/python/cpython/blob/3.7/Lib/subprocess.py
      #                                                            #L1426
      # [2] https://github.com/iterative/dvc/issues/2506
      #                                           #issuecomment-535396799
      kwargs["shell"] = os.name == "nt"
      return kwargs
  
file_path: dvc/dvc/stage/run.py
imports: import os
  import signal
  import subprocess
  import threading
  from dvc.log import logger
  from dvc.utils import fix_env
  from .decorators import unlocked_repo
  from .exceptions import StageCmdFailedError
label_desc: Use image node_id 4 for calling a global function with example usage: prepare_kwargs(stage, run_env) and returns: kwargs