code: def num_gpus(refresh=False):
      global NUM_GPUS
      if NUM_GPUS is None or refresh:
          n = 0
          try:
              n = mx.context.num_gpus()
          except mx.base.MXNetError as e:
              logger.error(f"Failure when querying GPU: {e}")
          NUM_GPUS = n
      return NUM_GPUS
  
file_path: gluonts/src/gluonts/mx/context.py
imports: import functools
  import logging
  import re
  from typing import Union
  import mxnet
label_desc: Use image node_id 1 for calling a global function with example usage: num_gpus(refresh) and returns: NUM_GPUS