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: Performs one step and maybe returns a reward.
docstr_tok: ["Performs","one","step","and","maybe","returns","a","reward","."]
code: def step(self, action: types.NestedArray) -> dm_env.TimeStep:
      """Performs one step and maybe returns a reward."""
      timestep = self.environment.step(action)
      self._delayed_reward = tree.map_structure(
          operator.iadd, self._delayed_reward, timestep.reward
      )
      self._accumulation_counter += 1
  
      if (
          self._accumuation_period is not None
          and self._accumulation_counter == self._accumuation_period
      ) or timestep.last():
          timestep = timestep._replace(reward=self._delayed_reward)
          self._accumulation_counter = 0
          self._delayed_reward = self._zero_reward
      else:
          timestep = timestep._replace(reward=self._zero_reward)
  
      return timestep
  
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 4 for calling the DelayedRewardWrapper obj's underlying member method code with example usage: obj.step(action) and returns: timestep