class_docstr: Implements delayed reward on environments.
  
  This wrapper sparsifies any environment by adding a reward delay. Instead of
  returning a reward at each step, the wrapped environment returns the
  accumulated reward every N steps or at the end of an episode, whichever comes
  first. This does not change the optimal expected return, but typically makes
  the environment harder by adding exploration and longer term dependencies.
class_docstr_tok: ["Implements","delayed","reward","on","environments",".","This","wrapper","sparsifies","any","environment","by","adding","a","reward","delay",".","Instead","of","returning","a","reward","at","each","step",",","the","wrapped","environment","returns","the","accumulated","reward","every","N","steps","or","at","the","end","of","an","episode",",","whichever","comes","first",".","This","does","not","change","the","optimal","expected","return",",","but","typically","makes","the","environment","harder","by","adding","exploration","and","longer","term","dependencies","."]
docstr: Initializes a `DelayedRewardWrapper`.
  
  Args:
    environment: An environment conforming to the dm_env.Environment
      interface.
   accumulation_period: number of steps to accumulate the reward over. If
     `accumulation_period` is an integer, reward is accumulated and returned
     every `accumulation_period` steps, and at the end of an episode. If
     `accumulation_period` is None, reward is only returned at the end of an
     episode. If `accumulation_period`=1, this wrapper is a no-op.
docstr_tok: ["Initializes","a","`","DelayedRewardWrapper","`",".","Args",":","environment",":","An","environment","conforming","to","the","dm_env.Environment","interface",".","accumulation_period",":","number","of","steps","to","accumulate","the","reward","over",".","If","`","accumulation_period","`","is","an","integer",",","reward","is","accumulated","and","returned","every","`","accumulation_period","`","steps",",","and","at","the","end","of","an","episode",".","If","`","accumulation_period","`","is","None",",","reward","is","only","returned","at","the","end","of","an","episode",".","If","`","accumulation_period","`","=1",",","this","wrapper","is","a","no-op","."]
code: def __init__(
      self,
      environment: dm_env.Environment,
      accumulation_period: Optional[int] = 1,
  ):
      """Initializes a `DelayedRewardWrapper`.
  
      Args:
        environment: An environment conforming to the dm_env.Environment
          interface.
       accumulation_period: number of steps to accumulate the reward over. If
         `accumulation_period` is an integer, reward is accumulated and returned
         every `accumulation_period` steps, and at the end of an episode. If
         `accumulation_period` is None, reward is only returned at the end of an
         episode. If `accumulation_period`=1, this wrapper is a no-op.
      """
  
      super().__init__(environment)
      if accumulation_period is not None and accumulation_period < 1:
          raise ValueError(
              f"Accumuluation period is {accumulation_period} but should be greater than 1."
          )
      self._accumuation_period = accumulation_period
      self._delayed_reward = self._zero_reward
      self._accumulation_counter = 0
  
file_path: acme/acme/wrappers/delayed_reward.py
imports: import operator
  from typing import Optional
  from acme import types
  from acme.wrappers import base
  import dm_env
  import numpy
  import tree
label_desc: Use image node_id 1 to create a new DelayedRewardWrapper object from inherited base classes: base with example: obj = DelayedRewardWrapper(environment, accumulation_period)