text: import logging
  import os
  import subprocess
  import sys
  
  
  def cpuStats():
      import psutil
      print(sys.version)
      print(psutil.cpu_percent())
      print(psutil.virtual_memory())  # physical memory usage
      pid = os.getpid()
      py = psutil.Process(pid)
      memoryUse = py.memory_info()[0] / 2.**30  # memory use in GB...I think
      print('memory GB:', memoryUse)
  
  
  def get_gpu_memory_map():
      """Get the current gpu usage.
  
      Returns
      -------
      usage: dict
          Keys are device ids as integers.
          Values are memory usage as integers in MB.
      """
      result = subprocess.check_output(
          ['nvidia-smi', '--query-gpu=memory.used', '--format=csv,nounits,noheader'],
          encoding='utf-8'
      )
      # Convert lines into a dictionary
      gpu_memory = [int(x) for x in result.strip().split('\n')]
      gpu_memory_map = dict(zip(range(len(gpu_memory)), gpu_memory))
      return gpu_memory_map
  
  
  def setup_logger(name, log_file, level=logging.INFO):
      """To setup as many loggers as you want"""
  
      handler = logging.FileHandler(log_file)
  
      logger = logging.getLogger(name)
      logger.setLevel(level)
      logger.addHandler(handler)
  
      return logger
  