class_docstr: Stationary Stochastic Bandit environment with per-arm features.
class_docstr_tok: ["Stationary","Stochastic","Bandit","environment","with","per-arm","features","."]
code: def _apply_action(self, action: np.ndarray) -> types.Array:
      if action.shape[0] != self.batch_size:
          raise ValueError("Number of actions must match batch size.")
      global_obs = self._observation[GLOBAL_KEY]
      item_obs = self._observation[PER_ARM_KEY]
      batch_size_range = range(self.batch_size)
      slotted_items = item_obs[
          np.expand_dims(batch_size_range, axis=1), action
      ]
      if self._click_model == ClickModel.GHOST_ACTIONS:
          chosen_items = self._choose_items_ghost_actions(
              global_obs, slotted_items
          )
      elif self._click_model == ClickModel.DISTANCE_BASED:
          chosen_items = self._choose_items_distance_based(
              global_obs, slotted_items
          )
      else:
          raise NotImplementedError(
              "Diversity model {} not implemented".format(
                  self._click_model
              )
          )
  
      if self._feedback_model == FeedbackModel.CASCADING:
          chosen_items = np.array(chosen_items, dtype=np.float32)
          chosen_values = (chosen_items < self._num_slots).astype(
              np.float32
          )
          return {
              "chosen_index": chosen_items,
              "chosen_value": chosen_values,
          }
      elif self._feedback_model == FeedbackModel.SCORE_VECTOR:
          chosen_values = (chosen_items < self._num_slots).astype(
              np.float32
          )
          return self._cascading_to_scorevector(
              chosen_items, chosen_values
          )
  
imports: from typing import Callable, Optional, Sequence, Text
  import numpy
  import tensorflow
  from tf_agents.bandits.environments import bandit_py_environment
  from tf_agents.bandits.specs import utils
  from tf_agents.specs import array_spec
  from tf_agents.trajectories import time_step
  from tf_agents.typing import types
label_desc: Use image node_id 5 for calling the RankingPyEnvironment obj's underlying member method code with example usage: obj._apply_action(action) and returns: dict, self