docstr: load data from d4rl dataset(https://github.com/rail-berkeley/d4rl#using-d4rl) to replay memory.
  
  Args:
      dataset(dict): dataset that contains:
                      observations (np.float32): shape of (batch_size, obs_dim),
                      next_observations (np.int32): shape of (batch_size, obs_dim),
                      actions (np.float32): shape of (batch_size, act_dim),
                      rewards (np.float32): shape of (batch_size),
                      terminals (bool): shape of (batch_size)
  
  Example:
  
  .. code-block:: python
  
      import gym
      import d4rl
  
      env = gym.make("hopper-medium-v0")
      rpm = ReplayMemory(max_size=int(2e6), obs_dim=11, act_dim=3)
      rpm.load_from_d4rl(d4rl.qlearning_dataset(env))
  
      # Output
  
      # Dataset Info: 
      # key: observations,        shape: (999981, 11),    dtype: float32
      # key: actions,     shape: (999981, 3),     dtype: float32
      # key: next_observations,   shape: (999981, 11),    dtype: float32
      # key: rewards,     shape: (999981,),       dtype: float32
      # key: terminals,   shape: (999981,),       dtype: bool
      # Number of terminals on: 3045
docstr_tok: ["load","data","from","d4rl","dataset","(","https",":","\/\/github.com\/rail-berkeley\/d4rl","#","using-d4rl",")","to","replay","memory",".","Args",":","dataset","(","dict",")",":","dataset","that","contains",":","observations","(","np.float32",")",":","shape","of","(","batch_size",",","obs_dim",")",",","next_observations","(","np.int32",")",":","shape","of","(","batch_size",",","obs_dim",")",",","actions","(","np.float32",")",":","shape","of","(","batch_size",",","act_dim",")",",","rewards","(","np.float32",")",":","shape","of","(","batch_size",")",",","terminals","(","bool",")",":","shape","of","(","batch_size",")","Example",":","..","code-block",":",":","python","import","gym","import","d4rl","env","=","gym.make","(","``","hopper-medium-v0","''",")","rpm","=","ReplayMemory","(","max_size=int","(","2e6",")",",","obs_dim=11",",","act_dim=3",")","rpm.load_from_d4rl","(","d4rl.qlearning_dataset","(","env",")",")","#","Output","#","Dataset","Info",":","#","key",":","observations",",","shape",":","(","999981",",","11",")",",","dtype",":","float32","#","key",":","actions",",","shape",":","(","999981",",","3",")",",","dtype",":","float32","#","key",":","next_observations",",","shape",":","(","999981",",","11",")",",","dtype",":","float32","#","key",":","rewards",",","shape",":","(","999981",",",")",",","dtype",":","float32","#","key",":","terminals",",","shape",":","(","999981",",",")",",","dtype",":","bool","#","Number","of","terminals","on",":","3045"]
code: def load_from_d4rl(self, dataset):
      """load data from d4rl dataset(https://github.com/rail-berkeley/d4rl#using-d4rl) to replay memory.
  
      Args:
          dataset(dict): dataset that contains:
                          observations (np.float32): shape of (batch_size, obs_dim),
                          next_observations (np.int32): shape of (batch_size, obs_dim),
                          actions (np.float32): shape of (batch_size, act_dim),
                          rewards (np.float32): shape of (batch_size),
                          terminals (bool): shape of (batch_size)
  
      Example:
  
      .. code-block:: python
  
          import gym
          import d4rl
  
          env = gym.make("hopper-medium-v0")
          rpm = ReplayMemory(max_size=int(2e6), obs_dim=11, act_dim=3)
          rpm.load_from_d4rl(d4rl.qlearning_dataset(env))
  
          # Output
  
          # Dataset Info:
          # key: observations,	shape: (999981, 11),	dtype: float32
          # key: actions,	shape: (999981, 3),	dtype: float32
          # key: next_observations,	shape: (999981, 11),	dtype: float32
          # key: rewards,	shape: (999981,),	dtype: float32
          # key: terminals,	shape: (999981,),	dtype: bool
          # Number of terminals on: 3045
  
      """
      logger.info("Dataset Info: ")
      for key in dataset:
          logger.info(
              "key: {},\tshape: {},\tdtype: {}".format(
                  key, dataset[key].shape, dataset[key].dtype
              )
          )
      assert "observations" in dataset
      assert "next_observations" in dataset
      assert "actions" in dataset
      assert "rewards" in dataset
      assert "terminals" in dataset
  
      self.obs = dataset["observations"]
      self.next_obs = dataset["next_observations"]
      self.action = dataset["actions"]
      self.reward = dataset["rewards"]
      self.terminal = dataset["terminals"]
      self._curr_size = dataset["terminals"].shape[0]
      assert (
          self._curr_size <= self.max_size
      ), "please set a proper max_size for ReplayMemory"
      logger.info(
          "Number of terminals on: {}".format(self.terminal.sum())
      )
  
file_path: PARL/parl/utils/replay_memory.py
imports: import numpy
  from parl.utils import logger
label_desc: Use image node_id 10 for calling the ReplayMemory obj's underlying member method code with example usage: obj.load_from_d4rl(dataset) without return types