class_docstr: Agent of Cartpole env.
  
  Args:
      algorithm(parl.Algorithm): algorithm used to solve the problem.
docstr: Sample an action `for exploration` when given an observation
  
  Args:
      obs(np.float32): shape of (obs_dim,)
  
  Returns:
      act(int): action
code: def sample(self, obs):
      """Sample an action `for exploration` when given an observation
  
      Args:
          obs(np.float32): shape of (obs_dim,)
  
      Returns:
          act(int): action
      """
      sample = np.random.random()
      if sample < self.e_greed:
          act = np.random.randint(self.act_dim)
      else:
          if np.random.random() < 0.01:
              act = np.random.randint(self.act_dim)
          else:
              act = self.predict(obs)
      self.e_greed = max(0.01, self.e_greed - self.e_greed_decrement)
      return act
  
file_path: PARL/examples/DQN/cartpole_agent.py
imports: import parl
  import paddle
  import numpy
label_desc: Use image node_id 2 for calling the CartpoleAgent obj's underlying member method code with example usage: obj.sample(obs) and returns: act