code: def get_msvc_environ(
      msvs_installation_path,
      msvs_version,
      msvc_toolset,
      cmd_runner,
      dry_run,
  ):
      if msvs_installation_path is None:
          program_files = (
              "Program Files"
              if msvs_version == "2022"
              else "Program Files (x86)"
          )
          msvs_base_dir = f"c:\\{program_files}\\Microsoft Visual Studio\\{msvs_version}"
      else:
          msvs_base_dir = os.path.join(
              msvs_installation_path, msvs_version
          )
  
      if os.path.exists(f"{msvs_base_dir}\\Community"):
          msvs_dir = f"{msvs_base_dir}\\Community"
      elif os.path.exists(f"{msvs_base_dir}\\Enterprise"):
          msvs_dir = f"{msvs_base_dir}\\Enterprise"
      else:
          raise RuntimeError(
              f"Microsoft Visual Studio {msvs_version} installation not found"
          )
  
      env_vars = {}
  
      # can't use NamedTemporaryFile or mkstemp because of child proces access issues
      with tempfile.TemporaryDirectory() as tmp_dir:
          env_vars_file_path = os.path.join(tmp_dir, "env_vars")
          cmd = f'"{msvs_dir}\\VC\\Auxiliary\\Build\\vcvars64.bat" -vcvars_ver={msvc_toolset} && set > {env_vars_file_path}'
          cmd_runner.run(cmd, run_even_with_dry_run=True, shell=True)
          with open(env_vars_file_path) as env_vars_file:
              for l in env_vars_file:
                  key, value = l[:-1].split("=", maxsplit=1)
                  env_vars[key] = value
  
      return env_vars
  
imports: import argparse
  import copy
  import logging
  import os
  import platform
  import subprocess
  import sys
  import tempfile
  from typing import Dict
label_desc: Use image node_id 10 for calling a global function with example usage: get_msvc_environ(msvs_installation_path, msvs_version, msvc_toolset, cmd_runner, dry_run) and returns: env_vars