docstr: Our monkey-patched pynvml._nvmlGetFunctionPointer().
  
  See also:
      test_gpustat::NvidiaDriverMock for test scenarios. See #107.
docstr_tok: ["Our","monkey-patched","pynvml._nvmlGetFunctionPointer","(",")",".","See","also",":","test_gpustat",":",":NvidiaDriverMock","for","test","scenarios",".","See","#","107","."]
code: def _nvmlGetFunctionPointer(name):
      """Our monkey-patched pynvml._nvmlGetFunctionPointer().
  
      See also:
          test_gpustat::NvidiaDriverMock for test scenarios. See #107.
      """
      M = pynvml_monkeypatch
  
      try:
          ret = M.original_nvmlGetFunctionPointer(name)
          return ret
      except pynvml.NVMLError_FunctionNotFound:  # type: ignore
          if name in M.FUNCTION_FALLBACKS:
              # Lack of ...Processes_v3 APIs happens for
              # OLD drivers < 510.39.01 && pynvml >= 11.510, where
              # we fallback to v2 APIs. (see #107 for more details)
  
              ret = M.original_nvmlGetFunctionPointer(
                  M.FUNCTION_FALLBACKS[name]
              )
              # populate the cache, so this handler won't get executed again
              pynvml._nvmlGetFunctionPointer_cache[name] = ret
  
          else:
              # Unknown case, cannot handle. re-raise again
              raise
  
      return ret
  
file_path: gpustat/gpustat/nvml.py
imports: import atexit
  import functools
  import os
  import sys
  import textwrap
  import warnings
label_desc: Use image node_id 2 for calling the pynvml_monkeypatch obj's underlying member method code with example usage: obj._nvmlGetFunctionPointer(name) and returns: ret, ret