class_docstr: Implements piecewise stationary finite-armed Bernoulli Bandits.
  
  This environment implements piecewise stationary finite-armed non-contextual
  Bernoulli Bandit environment as a subclass of BanditPyEnvironment.
  With respect to Bernoulli stationary environment, the reward distribution
  parameters undergo abrupt changes at given time steps. The current time is
  kept by the environment and increased by a unit at each call of _apply_action.
  For each stationary piece, the reward distribution is 0/1 (Bernoulli) with
  the parameter p valid for the current piece.
  
  Examples:
  
  means = [[0.1, 0.5], [0.5, 0.1], [0.5, 0.5]]  # 3 pieces, 2 arms.
  
  def constant_duration_gen(delta):
    while True:
      yield delta
  
  env_piecewise_10_steps = PiecewiseBernoulliPyEnvironment(
    means, constant_duration_gen(10))
  
  def random_duration_gen(a, b):
     while True:
       yield random.randint(a, b)
  
  env_rnd_piecewise_10_to_20_steps =  PiecewiseBernoulliPyEnvironment(
    means, random_duration_gen(10, 20))
  
  For a reference on bandits 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)
  A paper using piecewise stationary environments is Qingyun Wu, Naveen Iyer,
  Hongning Wang, ``Learning Contextual Bandits in a Non-stationary
  Environment,'' Proceedings of the 2017 ACM on Conference on Information and
  Knowledge Management (https://arxiv.org/pdf/1805.09365.pdf.)
code: def _apply_action(
      self, action: types.NestedArray
  ) -> types.NestedArray:
      reward = np.floor(
          self._piece_means[self._current_piece, action]
          + np.random.random((self._batch_size,))
      )
      self._increment_time()
      return reward
  
file_path: agents/tf_agents/bandits/environments/piecewise_bernoulli_py_environment.py
imports: from typing import Callable, Optional
  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 6 for calling the PiecewiseBernoulliPyEnvironment obj's underlying member method code with example usage: obj._apply_action(action) and returns: reward