class_docstr: | `alias`: ``parl.Agent``
  | `alias`: ``parl.core.torch.agent.Agent``
  
  | Agent is one of the three basic classes of PARL.
  
  | It is responsible for interacting with the environment and collecting data for training the policy.
  | To implement a customized ``Agent``, users can:
  
    .. code-block:: python
  
      import parl
  
      class MyAgent(parl.Agent):
          def __init__(self, algorithm, act_dim):
              super(MyAgent, self).__init__(algorithm)
              self.act_dim = act_dim
  
  Attributes:
      device (torch.device): select GPU/CPU to be used.
      alg (parl.Algorithm): algorithm of this agent.
  
  Public Functions:
      - ``sample``: return a noisy action to perform exploration according to the policy.
      - ``predict``: return an estimate Q function given current observation.
      - ``learn``: update the parameters of self.alg.
      - ``save``: save parameters of the ``agent`` to a given path.
      - ``restore``: restore previous saved parameters from a given path.
      - ``train``: set the agent in training mode.
      - ``eval``: set the agent in evaluation mode.
  
  Todo:
      - allow users to get parameters of a specified model by specifying the model's name in ``get_weights()``.
docstr: Restore previously saved parameters.
  This method requires a model that describes the network structure.
  The save_path argument is typically a value previously passed to ``save()``.
  
  Args:
      save_path(str): path where parameters were previously saved.
      model(parl.Model): model that describes the neural network structure. If None, will use self.alg.model.
      map_location: a function, torch.device, string or a dict specifying how to remap storage locations
  
  Raises:
      ValueError: if model is None and self.alg does not exist.
  
  Example:
  
  .. code-block:: python
  
      agent = AtariAgent()
      agent.save('./model.ckpt')
      agent.restore('./model.ckpt')
      
      agent.restore('./model.ckpt', map_location=torch.device('cpu')) # load gpu-trained model in cpu machine
docstr_tok: ["Restore","previously","saved","parameters",".","This","method","requires","a","model","that","describes","the","network","structure",".","The","save_path","argument","is","typically","a","value","previously","passed","to","``","save","(",")","``",".","Args",":","save_path","(","str",")",":","path","where","parameters","were","previously","saved",".","model","(","parl.Model",")",":","model","that","describes","the","neural","network","structure",".","If","None",",","will","use","self.alg.model",".","map_location",":","a","function",",","torch.device",",","string","or","a","dict","specifying","how","to","remap","storage","locations","Raises",":","ValueError",":","if","model","is","None","and","self.alg","does","not","exist",".","Example",":","..","code-block",":",":","python","agent","=","AtariAgent","(",")","agent.save","(","'.\/model.ckpt","'",")","agent.restore","(","'.\/model.ckpt","'",")","agent.restore","(","'.\/model.ckpt","'",",","map_location=torch.device","(","'cpu","'",")",")","#","load","gpu-trained","model","in","cpu","machine"]
code: def restore(self, save_path, model=None, map_location=None):
      """Restore previously saved parameters.
      This method requires a model that describes the network structure.
      The save_path argument is typically a value previously passed to ``save()``.
  
      Args:
          save_path(str): path where parameters were previously saved.
          model(parl.Model): model that describes the neural network structure. If None, will use self.alg.model.
          map_location: a function, torch.device, string or a dict specifying how to remap storage locations
  
      Raises:
          ValueError: if model is None and self.alg does not exist.
  
      Example:
  
      .. code-block:: python
  
          agent = AtariAgent()
          agent.save('./model.ckpt')
          agent.restore('./model.ckpt')
  
          agent.restore('./model.ckpt', map_location=torch.device('cpu')) # load gpu-trained model in cpu machine
      """
  
      if model is None:
          model = self.alg.model
      checkpoint = torch.load(save_path, map_location=map_location)
      model.load_state_dict(checkpoint)
  
file_path: PARL/parl/core/torch/agent.py
imports: import warnings
  import os
  import torch
  from parl.core.agent_base import AgentBase
  from parl.core.torch.algorithm import Algorithm
  from parl.utils import machine_info
label_desc: Use image node_id 6 for calling the Agent obj's underlying member method code with example usage: obj.restore(save_path, model, map_location) without return types