code: def check_gpu(use_gpu):
      """
      Log error and exit when set use_gpu=true in paddlepaddle
      cpu version.
      """
      err = (
          "Config use_gpu cannot be set as true while you are "
          "using paddlepaddle cpu version ! \nPlease try: \n"
          "\t1. Install paddlepaddle-gpu to run model on GPU \n"
          "\t2. Set use_gpu as false in config file to run "
          "model on CPU"
      )
      if use_gpu:
          try:
              if not paddle.is_compiled_with_cuda():
                  print(err)
                  sys.exit(1)
          except:
              print("Fail to check gpu state.")
              sys.exit(1)
  
imports: import sys
  import os
  import errno
  import paddle
label_desc: Use image node_id 2 for calling a global function with example usage: check_gpu(use_gpu) without return types