code: def add_compile_configvars():
      config.add(
          "mode",
          "Default compilation mode",
          ConfigParam("Mode", apply=_filter_mode),
          in_c_key=False,
      )
  
      param = "g++"
  
      # Test whether or not g++ is present: disable C code if it is not.
      try:
          rc = call_subprocess_Popen(["g++", "-v"])
      except OSError:
          rc = 1
  
      # Anaconda on Windows has mingw-w64 packages including GCC, but it may not be on PATH.
      if rc != 0:
          if sys.platform == "win32":
              mingw_w64_gcc = os.path.join(
                  os.path.dirname(sys.executable),
                  "Library",
                  "mingw-w64",
                  "bin",
                  "g++",
              )
              try:
                  rc = call_subprocess_Popen([mingw_w64_gcc, "-v"])
                  if rc == 0:
                      maybe_add_to_os_environ_pathlist(
                          "PATH", os.path.dirname(mingw_w64_gcc)
                      )
              except OSError:
                  rc = 1
              if rc != 0:
                  _logger.warning(
                      "g++ not available, if using conda: `conda install m2w64-toolchain`"
                  )
  
      if rc != 0:
          param = ""
  
      # On Mac/FreeBSD we test for 'clang++' and use it by default
      if sys.platform == "darwin" or sys.platform.startswith("freebsd"):
          try:
              rc = call_subprocess_Popen(["clang++", "-v"])
              if rc == 0:
                  param = "clang++"
          except OSError:
              pass
  
      # Try to find the full compiler path from the name
      if param != "":
          newp = find_executable(param)
          if newp is not None:
              param = newp
          del newp
  
      # to support path that includes spaces, we need to wrap it with double quotes on Windows
      if param and os.name == "nt":
          param = f'"{param}"'
  
      config.add(
          "cxx",
          "The C++ compiler to use. Currently only g++ is"
          " supported, but supporting additional compilers should not be "
          "too difficult. "
          "If it is empty, no C++ code is compiled.",
          StrParam(param, validate=_warn_cxx),
          in_c_key=False,
      )
      del param
  
      if rc == 0 and config.cxx != "":
          # Keep the default linker the same as the one for the mode FAST_RUN
          config.add(
              "linker",
              "Default linker used if the pytensor flags mode is Mode",
              EnumStr(
                  "cvm",
                  [
                      "c|py",
                      "py",
                      "c",
                      "c|py_nogc",
                      "vm",
                      "vm_nogc",
                      "cvm_nogc",
                  ],
              ),
              in_c_key=False,
          )
      else:
          # g++ is not present or the user disabled it,
          # linker should default to python only.
          config.add(
              "linker",
              "Default linker used if the pytensor flags mode is Mode",
              EnumStr("vm", ["py", "vm_nogc"]),
              in_c_key=False,
          )
          if type(config).cxx.is_default:
              # If the user provided an empty value for cxx, do not warn.
              _logger.warning(
                  "g++ not detected!  PyTensor will be unable to compile "
                  "C-implementations and will default to Python. "
                  "Performance may be severely degraded. "
                  "To remove this warning, set PyTensor flags cxx to an empty string."
              )
  
      # Keep the default value the same as the one for the mode FAST_RUN
      config.add(
          "allow_gc",
          "Do we default to delete intermediate results during PyTensor"
          " function calls? Doing so lowers the memory requirement, but"
          " asks that we reallocate memory at the next function call."
          " This is implemented for the default linker, but may not work"
          " for all linkers.",
          BoolParam(True),
          in_c_key=False,
      )
  
      # Keep the default optimizer the same as the one for the mode FAST_RUN
      config.add(
          "optimizer",
          "Default optimizer. If not None, will use this optimizer with the Mode",
          EnumStr(
              "o4",
              [
                  "o3",
                  "o2",
                  "o1",
                  "unsafe",
                  "fast_run",
                  "fast_compile",
                  "merge",
                  "None",
              ],
          ),
          in_c_key=False,
      )
  
      config.add(
          "optimizer_verbose",
          "If True, we print all optimization being applied",
          BoolParam(False),
          in_c_key=False,
      )
  
      config.add(
          "on_opt_error",
          (
              "What to do when an optimization crashes: warn and skip it, raise "
              "the exception, or fall into the pdb debugger."
          ),
          EnumStr("warn", ["raise", "pdb", "ignore"]),
          in_c_key=False,
      )
  
      config.add(
          "nocleanup",
          "Suppress the deletion of code files that did not compile cleanly",
          BoolParam(False),
          in_c_key=False,
      )
  
      config.add(
          "on_unused_input",
          "What to do if a variable in the 'inputs' list of "
          " pytensor.function() is not used in the graph.",
          EnumStr("raise", ["warn", "ignore"]),
          in_c_key=False,
      )
  
      config.add(
          "gcc__cxxflags",
          "Extra compiler flags for gcc",
          StrParam(""),
          # Added elsewhere in the c key only when needed.
          in_c_key=False,
      )
  
      config.add(
          "cmodule__warn_no_version",
          "If True, will print a warning when compiling one or more Op "
          "with C code that can't be cached because there is no "
          "c_code_cache_version() function associated to at least one of "
          "those Ops.",
          BoolParam(False),
          in_c_key=False,
      )
  
      config.add(
          "cmodule__remove_gxx_opt",
          "If True, will remove the -O* parameter passed to g++."
          "This is useful to debug in gdb modules compiled by PyTensor."
          "The parameter -g is passed by default to g++",
          BoolParam(False),
          # TODO: change so that this isn't needed.
          # This can be done by handing this in compile_args()
          in_c_key=True,
      )
  
      config.add(
          "cmodule__compilation_warning",
          "If True, will print compilation warnings.",
          BoolParam(False),
          in_c_key=False,
      )
  
      config.add(
          "cmodule__preload_cache",
          "If set to True, will preload the C module cache at import time",
          BoolParam(False, mutable=False),
          in_c_key=False,
      )
  
      config.add(
          "cmodule__age_thresh_use",
          "In seconds. The time after which PyTensor won't reuse a compile c module.",
          # 24 days
          IntParam(60 * 60 * 24 * 24, mutable=False),
          in_c_key=False,
      )
  
      config.add(
          "cmodule__debug",
          "If True, define a DEBUG macro (if not exists) for any compiled C code.",
          BoolParam(False),
          in_c_key=True,
      )
  
      config.add(
          "compile__wait",
          """Time to wait before retrying to acquire the compile lock.""",
          IntParam(5, validate=_is_gt_0, mutable=False),
          in_c_key=False,
      )
  
      config.add(
          "compile__timeout",
          """In seconds, time that a process will wait before deciding to
      override an existing lock. An override only happens when the existing
      lock is held by the same owner *and* has not been 'refreshed' by this
      owner for more than this period. Refreshes are done every half timeout
      period for running processes.""",
          IntParam(
              _timeout_default,
              validate=_is_greater_or_equal_0,
              mutable=False,
          ),
          in_c_key=False,
      )
  
      config.add(
          "ctc__root",
          "Directory which contains the root of Baidu CTC library. It is assumed \
          that the compiled library is either inside the build, lib or lib64 \
          subdirectory, and the header inside the include directory.",
          StrParam("", mutable=False),
          in_c_key=False,
      )
  
imports: import errno
  import logging
  import os
  import platform
  import re
  import socket
  import sys
  import textwrap
  import numpy
  from setuptools._distutils.spawn import find_executable
  import pytensor
  from pytensor.configparser import BoolParam, ConfigParam, DeviceParam, EnumStr, FloatParam, IntParam, StrParam, _create_default_config
  from pytensor.utils import LOCAL_BITWIDTH, PYTHON_INT_BITWIDTH, call_subprocess_Popen, maybe_add_to_os_environ_pathlist, output_subprocess_Popen
label_desc: Use image node_id 19 for calling a global function with example usage: add_compile_configvars() without return types