code: def GetClocksThrottleReasons(handle):
      throttleReasons = [
          [
              nvmlClocksThrottleReasonGpuIdle,
              "clocks_throttle_reason_gpu_idle",
          ],
          [
              nvmlClocksThrottleReasonUserDefinedClocks,
              "clocks_throttle_reason_user_defined_clocks",
          ],
          [
              nvmlClocksThrottleReasonApplicationsClocksSetting,
              "clocks_throttle_reason_applications_clocks_setting",
          ],
          [
              nvmlClocksThrottleReasonSwPowerCap,
              "clocks_throttle_reason_sw_power_cap",
          ],
          [
              nvmlClocksThrottleReasonHwSlowdown,
              "clocks_throttle_reason_hw_slowdown",
          ],
          [
              nvmlClocksThrottleReasonUnknown,
              "clocks_throttle_reason_unknown",
          ],
      ]
  
      strResult = ""
  
      try:
          supportedClocksThrottleReasons = (
              nvmlDeviceGetSupportedClocksThrottleReasons(handle)
          )
          clocksThrottleReasons = (
              nvmlDeviceGetCurrentClocksThrottleReasons(handle)
          )
          strResult += "    <clocks_throttle_reasons>\n"
          for mask, name in throttleReasons:
              if name != "clocks_throttle_reason_user_defined_clocks":
                  if mask & supportedClocksThrottleReasons:
                      val = (
                          "Active"
                          if mask & clocksThrottleReasons
                          else "Not Active"
                      )
                  else:
                      val = handleError(NVML_ERROR_NOT_SUPPORTED)
                  strResult += "      <%s>%s</%s>\n" % (name, val, name)
          strResult += "    </clocks_throttle_reasons>\n"
      except NVMLError as err:
          strResult += (
              "    <clocks_throttle_reasons>%s</clocks_throttle_reasons>\n"
              % (handleError(err))
          )
  
      return strResult
  
file_path: nvidia-ml-py3/nvidia_smi.py
imports: from pynvml import *
  import datetime
label_desc: Use image node_id 7 for calling a global function with example usage: GetClocksThrottleReasons(handle) and returns: strResult