class_docstr: Record GPU information in each worker and respond to resource allocation of GPUs.
  
  Attributes:
      worker_vacant_gpus (dict): Record how many vacant gpus does each
                                 worker has.
      worker_used_gpus (dict): Record how many used gpus does each
                                 worker has.
class_docstr_tok: ["Record","GPU","information","in","each","worker","and","respond","to","resource","allocation","of","GPUs",".","Attributes",":","worker_vacant_gpus","(","dict",")",":","Record","how","many","vacant","gpus","does","each","worker","has",".","worker_used_gpus","(","dict",")",":","Record","how","many","used","gpus","does","each","worker","has","."]
docstr: allocate n_gpu GPUs from the worker
          
docstr_tok: ["allocate","n_gpu","GPUs","from","the","worker"]
code: def allocate(self, worker_address, n_gpu):
      """allocate n_gpu GPUs from the worker"""
      gpu = ",".join(self.worker_vacant_gpus[worker_address][0:n_gpu])
      self.worker_used_gpus[worker_address].extend(
          self.worker_vacant_gpus[worker_address][0:n_gpu]
      )
      self.worker_vacant_gpus[worker_address] = self.worker_vacant_gpus[
          worker_address
      ][n_gpu:]
      assert len(self.worker_vacant_gpus[worker_address]) >= 0
      return AllocatedGpu(worker_address, gpu)
  
file_path: PARL/parl/remote/gpu_resource.py
imports: from collections import defaultdict
  from parl.remote.message import AllocatedGpu
label_desc: Use image node_id 5 for calling the GpuResource obj's underlying member method code with example usage: obj.allocate(worker_address, n_gpu) and returns: AllocatedGpu