class_docstr: Implements finite-armed Bernoulli Bandits.
  
  This environment implements a finite-armed non-contextual Bernoulli Bandit
  environment as a subclass of BanditPyEnvironment. For every arm, the reward
  distribution is 0/1 (Bernoulli) with parameter p set at the initialization.
  For a reference, see e.g., Example 1.1 in "A Tutorial on Thompson Sampling" by
  Russo et al. (https://web.stanford.edu/~bvr/pubs/TS_Tutorial.pdf)
class_docstr_tok: ["Implements","finite-armed","Bernoulli","Bandits",".","This","environment","implements","a","finite-armed","non-contextual","Bernoulli","Bandit","environment","as","a","subclass","of","BanditPyEnvironment",".","For","every","arm",",","the","reward","distribution","is","0\/1","(","Bernoulli",")","with","parameter","p","set","at","the","initialization",".","For","a","reference",",","see","e.g.",",","Example","1.1","in","``","A","Tutorial","on","Thompson","Sampling","''","by","Russo","et","al",".","(","https",":","\/\/web.stanford.edu\/~bvr\/pubs\/TS_Tutorial.pdf",")"]
docstr: Initializes a Bernoulli Bandit environment.
  
  Args:
    means: vector of floats in [0, 1], the mean rewards for actions. The
      number of arms is determined by its length.
    batch_size: (int) The batch size.
docstr_tok: ["Initializes","a","Bernoulli","Bandit","environment",".","Args",":","means",":","vector","of","floats","in","[","0",",","1","]",",","the","mean","rewards","for","actions",".","The","number","of","arms","is","determined","by","its","length",".","batch_size",":","(","int",")","The","batch","size","."]
code: def __init__(
      self,
      means: Sequence[types.Float],
      batch_size: Optional[types.Int] = 1,
  ):
      """Initializes a Bernoulli Bandit environment.
  
      Args:
        means: vector of floats in [0, 1], the mean rewards for actions. The
          number of arms is determined by its length.
        batch_size: (int) The batch size.
      """
      self._num_actions = len(means)
      self._means = means
      self._batch_size = batch_size
      if any(x < 0 or x > 1 for x in means):
          raise ValueError("All parameters should be floats in [0, 1].")
  
      action_spec = array_spec.BoundedArraySpec(
          shape=(),
          dtype=np.int32,
          minimum=0,
          maximum=self._num_actions - 1,
          name="action",
      )
      observation_spec = array_spec.ArraySpec(
          shape=(), dtype=np.float32, name="observation"
      )
      super(BernoulliPyEnvironment, self).__init__(
          observation_spec, action_spec
      )
  
file_path: agents/tf_agents/bandits/environments/bernoulli_py_environment.py
imports: from typing import Optional, Sequence
  import gin
  import numpy
  from tf_agents.bandits.environments import bandit_py_environment
  from tf_agents.specs import array_spec
  from tf_agents.typing import types
label_desc: Use image node_id 1 to create a new BernoulliPyEnvironment object from inherited base classes: bandit_py_environment with example: obj = BernoulliPyEnvironment(means, batch_size)