class_docstr: | `alias`: ``parl.Agent``
  | `alias`: ``parl.core.paddle.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:
      alg (parl.algorithm): algorithm of this agent.
  
  Public Functions:
      - ``sample``: return a noisy action to perform exploration according to the policy.
      - ``predict``: return an action given current observation.
      - ``learn``: update the parameters of self.alg using the `learn_program` defined in `build_program()`.
      - ``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: Saves input Layer or function as ``paddle.jit.TranslatedLayer`` format model, which can be used for inference.
  
  Args:
      save_path(str): where to save the inference_model.
      model(parl.Model): model that describes the policy network structure. If None, will use self.alg.model.
      input_shape_list(list): shape of all inputs of the saved model's forward method.
      input_dtype_list(list): dtype of all inputs of the saved model's forward method.
  
  Example:
  
  .. code-block:: python
  
      agent = AtariAgent()
      agent.save_inference_model('./inference_model_dir', [[None, 128]], ['float32'])
  
  
  Example with actor-critic:
  
  .. code-block:: python
  
      agent = AtariAgent()
      agent.save_inference_model('./inference_ac_model_dir', [[None, 128]], ['float32'], agent.alg.model.actor_model)
docstr_tok: ["Saves","input","Layer","or","function","as","``","paddle.jit.TranslatedLayer","``","format","model",",","which","can","be","used","for","inference",".","Args",":","save_path","(","str",")",":","where","to","save","the","inference_model",".","model","(","parl.Model",")",":","model","that","describes","the","policy","network","structure",".","If","None",",","will","use","self.alg.model",".","input_shape_list","(","list",")",":","shape","of","all","inputs","of","the","saved","model","'s","forward","method",".","input_dtype_list","(","list",")",":","dtype","of","all","inputs","of","the","saved","model","'s","forward","method",".","Example",":","..","code-block",":",":","python","agent","=","AtariAgent","(",")","agent.save_inference_model","(","'.\/inference_model_dir","'",",","[","[","None",",","128","]","]",",","[","'float32","'","]",")","Example","with","actor-critic",":","..","code-block",":",":","python","agent","=","AtariAgent","(",")","agent.save_inference_model","(","'.\/inference_ac_model_dir","'",",","[","[","None",",","128","]","]",",","[","'float32","'","]",",","agent.alg.model.actor_model",")"]
code: def save_inference_model(
      self, save_path, input_shape_list, input_dtype_list, model=None
  ):
      """
      Saves input Layer or function as ``paddle.jit.TranslatedLayer`` format model, which can be used for inference.
  
      Args:
          save_path(str): where to save the inference_model.
          model(parl.Model): model that describes the policy network structure. If None, will use self.alg.model.
          input_shape_list(list): shape of all inputs of the saved model's forward method.
          input_dtype_list(list): dtype of all inputs of the saved model's forward method.
  
      Example:
  
      .. code-block:: python
  
          agent = AtariAgent()
          agent.save_inference_model('./inference_model_dir', [[None, 128]], ['float32'])
  
  
      Example with actor-critic:
  
      .. code-block:: python
  
          agent = AtariAgent()
          agent.save_inference_model('./inference_ac_model_dir', [[None, 128]], ['float32'], agent.alg.model.actor_model)
  
      """
      if model is None:
          model = self.alg.model
      assert callable(
          getattr(model, "forward", None)
      ), "forward should be a function in model class."
      assert (
          model.forward.__func__
          is not super(model.__class__, model).forward.__func__
      ), "model needs to implement forward method."
      assert isinstance(
          input_shape_list, list
      ), "Type of input_shape_list in save_inference_model() should be list, but received {}".format(
          type(input_shape_list)
      )
      assert isinstance(
          input_dtype_list, list
      ), "Type of input_dtype_list in save_inference_model() should be list, but received {}".format(
          type(input_dtype_list)
      )
      assert len(input_shape_list) == len(input_dtype_list)
      input_spec = []
      for input_shape, input_type in zip(
          input_shape_list, input_dtype_list
      ):
          input_spec.append(
              InputSpec(shape=input_shape, dtype=input_type)
          )
      paddle.jit.save(model, save_path, input_spec)
  
file_path: PARL/parl/core/paddle/agent.py
imports: import os
  import paddle
  from paddle.static import InputSpec
  from parl.core.agent_base import AgentBase
  from parl.core.paddle.algorithm import Algorithm
label_desc: Use image node_id 6 for calling the Agent obj's underlying member method code with example usage: obj.save_inference_model(save_path, input_shape_list, input_dtype_list, model) without return types