code: def init_once():
      """Idempotent (per-process) initialization of PyNVML
  
      Notes
      -----
  
      Modifies global variables NVML_STATE and NVML_OWNER_PID"""
      global NVML_STATE, NVML_OWNER_PID
  
      if NVML_STATE in {
          NVMLState.DISABLED_PYNVML_NOT_AVAILABLE,
          NVMLState.DISABLED_CONFIG,
          NVMLState.DISABLED_LIBRARY_NOT_FOUND,
          NVMLState.DISABLED_WSL_INSUFFICIENT_DRIVER,
      }:
          return
      elif (
          NVML_STATE == NVMLState.INITIALIZED
          and NVML_OWNER_PID == os.getpid()
      ):
          return
      elif (
          NVML_STATE == NVMLState.UNINITIALIZED
          and not dask.config.get("distributed.diagnostics.nvml")
      ):
          NVML_STATE = NVMLState.DISABLED_CONFIG
          return
      elif (
          NVML_STATE == NVMLState.INITIALIZED
          and NVML_OWNER_PID != os.getpid()
      ) or NVML_STATE == NVMLState.UNINITIALIZED:
          try:
              pynvml.nvmlInit()
          except (
              pynvml.NVMLError_LibraryNotFound,
              pynvml.NVMLError_DriverNotLoaded,
              pynvml.NVMLError_Unknown,
          ):
              NVML_STATE = NVMLState.DISABLED_LIBRARY_NOT_FOUND
              return
  
          if _in_wsl() and parse_version(
              pynvml.nvmlSystemGetDriverVersion().decode()
          ) < parse_version(MINIMUM_WSL_VERSION):
              NVML_STATE = NVMLState.DISABLED_WSL_INSUFFICIENT_DRIVER
              return
          else:
              from distributed.worker import add_gpu_metrics
  
              # initialization was successful
              NVML_STATE = NVMLState.INITIALIZED
              NVML_OWNER_PID = os.getpid()
              add_gpu_metrics()
      else:
          raise RuntimeError(
              f"Unhandled initialisation state ({NVML_STATE=}, {NVML_OWNER_PID=})"
          )
  
imports: from __future__ import annotations
  import os
  from enum import IntEnum, auto
  from platform import uname
  from typing import NamedTuple
  from packaging.version import parse
  import dask
label_desc: Use image node_id 3 for calling a global function with example usage: init_once() without return types