<commit_before>"""NoOp Starts wrapper to allow stochastic initial state for deterministic Python environments."""

from typing import Optional

from acme.wrappers import base
import dm_env
import numpy as np

class NoopStartsWrapper(base.EnvironmentWrapper):
  """Implements random noop starts to episodes."""

  def __init__(self,
               environment: dm_env.Environment,
               noop_action: int = 0,
               noop_max: int = 30,
               seed: Optional[int] = None):
    """Initializes a `_NoopReset` wrapper.

    Args:
      environment: An Atari environment.
      noop_action: The noop action used to step the environment for random initialisation.
      noop_max: The maximal number of noop actions at the start of an episode.
      seed: The random seed used to sample the number of noops.
    """
    if noop_max < 0:
      raise ValueError(
        "Maximal number of no-ops after reset cannot be negative. "
        f"Received noop_max={noop_max}"
      )

    super().__init__(environment)
    self.np_random = np.random.RandomState(seed)
    self._noop_max = noop_max<commit_msg>docs: correct documentation now wrapper is not Atari specific<commit_after>"""NoOp Starts wrapper to allow stochastic initial state for deterministic Python environments."""

from typing import Optional

from acme.wrappers import base
import dm_env
import numpy as np

class NoopStartsWrapper(base.EnvironmentWrapper):
  """Implements random noop starts to episodes.

  This introduces randomness into an otherwise deterministic environment.

  Note that the base environment must support a no-op action and the value
  of this action must be known and provided to this wrapper.
  """

  def __init__(self,
               environment: dm_env.Environment,
               noop_action: int = 0,
               noop_max: int = 30,
               seed: Optional[int] = None):
    """Initializes a `NoopStartsWrapper` wrapper.

    Args:
      environment: An environment conforming to the dm_env.Environment interface.
      noop_action: The noop action used to step the environment for random initialisation.
      noop_max: The maximal number of noop actions at the start of an episode.
      seed: The random seed used to sample the number of noops.
    """
    if noop_max < 0:
      raise ValueError(
        "Maximal number of no-ops after reset cannot be negative. "
        f"Received noop_max={noop_max}"
      )

    super().__init__(environment)
    self.np_random = np.random.RandomState(seed)
    self._noop_max = noop_max
{'fraction_non_alphanumeric': 0.06708513142408788, 'fraction_numerical': 0.003138485680659082, 'mean_word_length': 3.009433962264151, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6617689', 'n_tokens_mistral': 703, 'n_tokens_neox': 665, 'n_words': 271}