code: def validate_cuda_config(environ_cp):
      """Run find_cuda_config.py and return cuda_toolkit_path, or None."""
  
      def maybe_encode_env(env):
          """Encodes unicode in env to str on Windows python 2.x."""
          if not is_windows() or sys.version_info[0] != 2:
              return env
          for k, v in env.items():
              if isinstance(k, unicode):
                  k = k.encode("ascii")
              if isinstance(v, unicode):
                  v = v.encode("ascii")
              env[k] = v
          return env
  
      cuda_libraries = ["cuda", "cudnn"]
      if is_linux():
          if environ_cp.get("TF_NCCL_VERSION", None):
              cuda_libraries.append("nccl")
  
      find_cuda_script = os.path.join(
          pathlib.Path(__file__).parent.resolve(),
          "third_party/tsl/third_party/gpus/find_cuda_config.py",
      )
      if not os.path.isfile(find_cuda_script):
          raise FileNotFoundError(
              "Can't find 'find_cuda_config.py' script inside working directory,"
              f" expected in {find_cuda_script}"
          )
      proc = subprocess.Popen(
          [environ_cp["PYTHON_BIN_PATH"], find_cuda_script]
          + cuda_libraries,
          stdout=subprocess.PIPE,
          env=maybe_encode_env(environ_cp),
      )
  
      if proc.wait():
          # Errors from find_cuda_config.py were sent to stderr.
          print("Asking for detailed CUDA configuration...\n")
          return False
  
      config = dict(
          tuple(line.decode("ascii").rstrip().split(": "))
          for line in proc.stdout
      )
  
      print("Found CUDA %s in:" % config["cuda_version"])
      print("    %s" % config["cuda_library_dir"])
      print("    %s" % config["cuda_include_dir"])
  
      print("Found cuDNN %s in:" % config["cudnn_version"])
      print("    %s" % config["cudnn_library_dir"])
      print("    %s" % config["cudnn_include_dir"])
  
      if config.get("nccl_version", None):
          print("Found NCCL %s in:" % config["nccl_version"])
          print("    %s" % config["nccl_library_dir"])
          print("    %s" % config["nccl_include_dir"])
  
      print("\n")
  
      environ_cp["CUDA_TOOLKIT_PATH"] = config["cuda_toolkit_path"]
      return True
  
imports: import argparse
  import os
  import pathlib
  import platform
  import re
  import subprocess
  import sys
label_desc: Use image node_id 37 for calling a global function with example usage: validate_cuda_config(environ_cp) and returns: True, env, False, env