class_docstr: Adder which adds from time to time some demonstrations.
  
  Lfd stands for Learning From Demonstrations and is the same technique
  as the one used in R2D3.
class_docstr_tok: ["Adder","which","adds","from","time","to","time","some","demonstrations",".","Lfd","stands","for","Learning","From","Demonstrations","and","is","the","same","technique","as","the","one","used","in","R2D3","."]
docstr: LfdAdder constructor.
  
  Args:
    adder: The underlying adder used to add mixed episodes.
    demonstrations: An iterator on infinite stream of (action, next_timestep)
      pairs. Episode boundaries are defined by TimeStep.FIRST and
      timestep.LAST markers. Note that the first action of an episode is
      ignored. Note also that proper uniform sampling of demonstrations is the
      responsibility of the iterator.
    initial_insert_count: Number of steps of demonstrations to add before
      adding any step of the collected episodes. Note that since only full
      episodes can be added, this number of steps is only a target.
    demonstration_ratio: Ratio of demonstration steps to add to the underlying
      adder. ratio = num_demonstration_steps_added / total_num_steps_added
      and must be in [0, 1).
      Note that this ratio is the desired ratio in the steady behavior
      and does not account for the initial inserts of demonstrations.
      Note also that this ratio is only a target ratio since the granularity
      is the episode.
docstr_tok: ["LfdAdder","constructor",".","Args",":","adder",":","The","underlying","adder","used","to","add","mixed","episodes",".","demonstrations",":","An","iterator","on","infinite","stream","of","(","action",",","next_timestep",")","pairs",".","Episode","boundaries","are","defined","by","TimeStep.FIRST","and","timestep.LAST","markers",".","Note","that","the","first","action","of","an","episode","is","ignored",".","Note","also","that","proper","uniform","sampling","of","demonstrations","is","the","responsibility","of","the","iterator",".","initial_insert_count",":","Number","of","steps","of","demonstrations","to","add","before","adding","any","step","of","the","collected","episodes",".","Note","that","since","only","full","episodes","can","be","added",",","this","number","of","steps","is","only","a","target",".","demonstration_ratio",":","Ratio","of","demonstration","steps","to","add","to","the","underlying","adder",".","ratio","=","num_demonstration_steps_added","\/","total_num_steps_added","and","must","be","in","[","0",",","1",")",".","Note","that","this","ratio","is","the","desired","ratio","in","the","steady","behavior","and","does","not","account","for","the","initial","inserts","of","demonstrations",".","Note","also","that","this","ratio","is","only","a","target","ratio","since","the","granularity","is","the","episode","."]
code: def __init__(
      self,
      adder: adders.Adder,
      demonstrations: Iterator[Tuple[Any, dm_env.TimeStep]],
      initial_insert_count: int,
      demonstration_ratio: float,
  ):
      """LfdAdder constructor.
  
      Args:
        adder: The underlying adder used to add mixed episodes.
        demonstrations: An iterator on infinite stream of (action, next_timestep)
          pairs. Episode boundaries are defined by TimeStep.FIRST and
          timestep.LAST markers. Note that the first action of an episode is
          ignored. Note also that proper uniform sampling of demonstrations is the
          responsibility of the iterator.
        initial_insert_count: Number of steps of demonstrations to add before
          adding any step of the collected episodes. Note that since only full
          episodes can be added, this number of steps is only a target.
        demonstration_ratio: Ratio of demonstration steps to add to the underlying
          adder. ratio = num_demonstration_steps_added / total_num_steps_added
          and must be in [0, 1).
          Note that this ratio is the desired ratio in the steady behavior
          and does not account for the initial inserts of demonstrations.
          Note also that this ratio is only a target ratio since the granularity
          is the episode.
      """
      self._adder = adder
      self._demonstrations = demonstrations
      self._demonstration_ratio = demonstration_ratio
      if demonstration_ratio < 0 or demonstration_ratio >= 1.0:
          raise ValueError("Invalid demonstration ratio.")
  
      # Number of demonstration steps that should have been added to the replay
      # buffer to meet the target demonstration ratio minus what has been really
      # added.
      # As a consequence:
      # - when this delta is zero, the effective ratio exactly matches the desired
      #   ratio
      # - when it is positive, more demonstrations need to be added to
      #   reestablish the balance
      # The initial value is set so that after exactly initial_insert_count
      # inserts of demonstration steps, _delta_demonstration_step_count will be
      # zero.
      self._delta_demonstration_step_count = (
          1.0 - self._demonstration_ratio
      ) * initial_insert_count
  
file_path: acme/acme/agents/jax/lfd/lfd_adder.py
imports: from typing import Any, Iterator, Tuple
  from acme import adders
  from acme import types
  import dm_env
label_desc: Use image node_id 1 to create a new LfdAdder object from inherited base classes: adders with example: obj = LfdAdder(adder, demonstrations, initial_insert_count, demonstration_ratio)