class_docstr: A drifting linear environment dynamics.
  
  This is a drifting linear environment which computes rewards as:
  
  rewards(t) = observation(t) * observation_to_reward(t) + additive_reward(t)
  
  where `t` is the environment time. `observation_to_reward` slowly rotates over
  time. The environment time is incremented in the base class after the reward
  is computed. The parameters `observation_to_reward` and `additive_reward` are
  updated at each time step.
  In order to preserve the norm of the `observation_to_reward` (and the range
  of values of the reward) the drift is applied in form of rotations, i.e.,
  
  observation_to_reward(t) = R(theta(t)) * observation_to_reward(t - 1)
  
  where `theta` is the angle of the rotation. The angle is sampled from a
  provided input distribution.
class_docstr_tok: ["A","drifting","linear","environment","dynamics",".","This","is","a","drifting","linear","environment","which","computes","rewards","as",":","rewards","(","t",")","=","observation","(","t",")","*","observation_to_reward","(","t",")","+","additive_reward","(","t",")","where","`","t","`","is","the","environment","time",".","`","observation_to_reward","`","slowly","rotates","over","time",".","The","environment","time","is","incremented","in","the","base","class","after","the","reward","is","computed",".","The","parameters","`","observation_to_reward","`","and","`","additive_reward","`","are","updated","at","each","time","step",".","In","order","to","preserve","the","norm","of","the","`","observation_to_reward","`","(","and","the","range","of","values","of","the","reward",")","the","drift","is","applied","in","form","of","rotations",",","i.e.",",","observation_to_reward","(","t",")","=","R","(","theta","(","t",")",")","*","observation_to_reward","(","t","-","1",")","where","`","theta","`","is","the","angle","of","the","rotation",".","The","angle","is","sampled","from","a","provided","input","distribution","."]
docstr: Initialize the parameters of the drifting linear dynamics.
  
  Args:
    observation_distribution: A distribution from tfp.distributions with shape
      `[batch_size, observation_dim]` Note that the values of `batch_size` and
      `observation_dim` are deduced from the distribution.
    observation_to_reward_distribution: A distribution from
      `tfp.distributions` with shape `[observation_dim, num_actions]`. The
      value `observation_dim` must match the second dimension of
      `observation_distribution`.
    drift_distribution: A scalar distribution from `tfp.distributions` of type
      tf.float32. It represents the angle of rotation.
    additive_reward_distribution: A distribution from `tfp.distributions` with
      shape `[num_actions]`. This models the non-contextual behavior of the
      bandit.
docstr_tok: ["Initialize","the","parameters","of","the","drifting","linear","dynamics",".","Args",":","observation_distribution",":","A","distribution","from","tfp.distributions","with","shape","`","[","batch_size",",","observation_dim","]","`","Note","that","the","values","of","`","batch_size","`","and","`","observation_dim","`","are","deduced","from","the","distribution",".","observation_to_reward_distribution",":","A","distribution","from","`","tfp.distributions","`","with","shape","`","[","observation_dim",",","num_actions","]","`",".","The","value","`","observation_dim","`","must","match","the","second","dimension","of","`","observation_distribution","`",".","drift_distribution",":","A","scalar","distribution","from","`","tfp.distributions","`","of","type","tf.float32",".","It","represents","the","angle","of","rotation",".","additive_reward_distribution",":","A","distribution","from","`","tfp.distributions","`","with","shape","`","[","num_actions","]","`",".","This","models","the","non-contextual","behavior","of","the","bandit","."]
code: def __init__(
      self,
      observation_distribution: types.Distribution,
      observation_to_reward_distribution: types.Distribution,
      drift_distribution: types.Distribution,
      additive_reward_distribution: types.Distribution,
  ):
      """Initialize the parameters of the drifting linear dynamics.
  
      Args:
        observation_distribution: A distribution from tfp.distributions with shape
          `[batch_size, observation_dim]` Note that the values of `batch_size` and
          `observation_dim` are deduced from the distribution.
        observation_to_reward_distribution: A distribution from
          `tfp.distributions` with shape `[observation_dim, num_actions]`. The
          value `observation_dim` must match the second dimension of
          `observation_distribution`.
        drift_distribution: A scalar distribution from `tfp.distributions` of type
          tf.float32. It represents the angle of rotation.
        additive_reward_distribution: A distribution from `tfp.distributions` with
          shape `[num_actions]`. This models the non-contextual behavior of the
          bandit.
      """
      self._observation_distribution = observation_distribution
      self._drift_distribution = drift_distribution
      self._observation_to_reward_distribution = (
          observation_to_reward_distribution
      )
      self._additive_reward_distribution = additive_reward_distribution
  
      observation_batch_shape = observation_distribution.batch_shape
      reward_batch_shape = additive_reward_distribution.batch_shape
      if observation_batch_shape.rank != 2:
          _raise_batch_shape_error(
              "observation_distribution", observation_batch_shape
          )
      if reward_batch_shape.rank != 1:
          _raise_batch_shape_error(
              "additive_reward_distribution", reward_batch_shape
          )
      if additive_reward_distribution.dtype != tf.float32:
          raise ValueError(
              "Reward  must have dtype float32; got {}".format(
                  self._reward.dtype
              )
          )
      self._observation_dim = (
          self._observation_distribution.batch_shape[1]
      )
  
      expected_observation_to_reward_shape = [
          tf.compat.dimension_value(
              self._observation_distribution.batch_shape[1:]
          ),
          tf.compat.dimension_value(
              self._additive_reward_distribution.batch_shape[0]
          ),
      ]
      observation_to_reward_shape = [
          tf.compat.dimension_value(x)
          for x in observation_to_reward_distribution.batch_shape
      ]
      if (
          observation_to_reward_shape
          != expected_observation_to_reward_shape
      ):
          raise ValueError(
              "Observation to reward has {} as expected shape; got {}".format(
                  expected_observation_to_reward_shape,
                  observation_to_reward_shape,
              )
          )
  
      self._current_observation_to_reward = tf.compat.v2.Variable(
          observation_to_reward_distribution.sample(),
          dtype=tf.float32,
          name="observation_to_reward",
      )
      self._current_additive_reward = tf.compat.v2.Variable(
          additive_reward_distribution.sample(),
          dtype=tf.float32,
          name="additive_reward",
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import gin
  import tensorflow
  from tf_agents.bandits.environments import non_stationary_stochastic_environment
  from tf_agents.specs import tensor_spec
  from tf_agents.typing import types
label_desc: Use image node_id 1 to create a new DriftingLinearDynamics object from inherited base classes: nsse with example: obj = DriftingLinearDynamics(observation_distribution, observation_to_reward_distribution, drift_distribution, additive_reward_distribution)