class_docstr: A ranking environment in which one can explicitly set positional bias.
  
  This environment assumes that the user's click is governed by two independent
  values: the relevance and the observation probability. Relevance is based on
  a random function whose input is the global and item features. The observation
  probability is a parameter list that sets observation probabilities for all of
  the slot positions. The observation prbabilities don't denpend on the context
  or the items placed in the slots.
  
  The user model: an item is clicked if it is observed and relevant. Hence,
  multiple items can be clicked in one sample.
class_docstr_tok: ["A","ranking","environment","in","which","one","can","explicitly","set","positional","bias",".","This","environment","assumes","that","the","user","'s","click","is","governed","by","two","independent","values",":","the","relevance","and","the","observation","probability",".","Relevance","is","based","on","a","random","function","whose","input","is","the","global","and","item","features",".","The","observation","probability","is","a","parameter","list","that","sets","observation","probabilities","for","all","of","the","slot","positions",".","The","observation","prbabilities","do","n't","denpend","on","the","context","or","the","items","placed","in","the","slots",".","The","user","model",":","an","item","is","clicked","if","it","is","observed","and","relevant",".","Hence",",","multiple","items","can","be","clicked","in","one","sample","."]
docstr: Initializes an instance of `ExplicitPositionalBiasRankingEnvironment`.
  
  Args:
    global_sampling_fn: A function that outputs a random 1d array or list of
      ints or floats. This output is the global context. Its shape and type
      must be consistent across calls.
    item_sampling_fn: A function that outputs a random 1 array or list of ints
      or floats (same type as the output of `global_context_sampling_fn`).
      This output is the per-arm context. Its shape must be consistent across
      calls.
    relevance_fn: A function that, called with global features and features of
      one item, returns click probabilities, given the item was observed.
    num_items: (int) the number of items in every sample.
    observation_probs: Observation probabilities for all slots. The length of
      this list determines the number of slots.
    batch_size: The batch size.
    name: The name of this environment instance.
docstr_tok: ["Initializes","an","instance","of","`","ExplicitPositionalBiasRankingEnvironment","`",".","Args",":","global_sampling_fn",":","A","function","that","outputs","a","random","1d","array","or","list","of","ints","or","floats",".","This","output","is","the","global","context",".","Its","shape","and","type","must","be","consistent","across","calls",".","item_sampling_fn",":","A","function","that","outputs","a","random","1","array","or","list","of","ints","or","floats","(","same","type","as","the","output","of","`","global_context_sampling_fn","`",")",".","This","output","is","the","per-arm","context",".","Its","shape","must","be","consistent","across","calls",".","relevance_fn",":","A","function","that",",","called","with","global","features","and","features","of","one","item",",","returns","click","probabilities",",","given","the","item","was","observed",".","num_items",":","(","int",")","the","number","of","items","in","every","sample",".","observation_probs",":","Observation","probabilities","for","all","slots",".","The","length","of","this","list","determines","the","number","of","slots",".","batch_size",":","The","batch","size",".","name",":","The","name","of","this","environment","instance","."]
code: def __init__(
      self,
      global_sampling_fn: Callable[[], types.Array],
      item_sampling_fn: Callable[[], types.Array],
      relevance_fn: Callable[[types.Array, types.Array], float],
      num_items: int,
      observation_probs: Sequence[float],
      batch_size: int = 1,
      name: Optional[Text] = None,
  ):
      """Initializes an instance of `ExplicitPositionalBiasRankingEnvironment`.
  
      Args:
        global_sampling_fn: A function that outputs a random 1d array or list of
          ints or floats. This output is the global context. Its shape and type
          must be consistent across calls.
        item_sampling_fn: A function that outputs a random 1 array or list of ints
          or floats (same type as the output of `global_context_sampling_fn`).
          This output is the per-arm context. Its shape must be consistent across
          calls.
        relevance_fn: A function that, called with global features and features of
          one item, returns click probabilities, given the item was observed.
        num_items: (int) the number of items in every sample.
        observation_probs: Observation probabilities for all slots. The length of
          this list determines the number of slots.
        batch_size: The batch size.
        name: The name of this environment instance.
      """
      self._global_sampling_fn = global_sampling_fn
      self._item_sampling_fn = item_sampling_fn
      self._num_items = num_items
  
      self._num_slots = len(observation_probs)
      self._observation_probs = np.array(observation_probs)
      if np.any(self._observation_probs > 1) or np.any(
          self._observation_probs < 0
      ):
          raise ValueError(
              "Observation probabilities need to be in [0, 1]."
          )
      self._relevance_fn = relevance_fn
      self._batch_size = batch_size
  
      global_spec = array_spec.ArraySpec.from_array(
          global_sampling_fn()
      )
      item_spec = array_spec.add_outer_dims_nest(
          array_spec.ArraySpec.from_array(item_sampling_fn()),
          (num_items,),
      )
      observation_spec = {
          GLOBAL_KEY: global_spec,
          PER_ARM_KEY: item_spec,
      }
      self._global_dim = global_spec.shape[0]
  
      action_spec = array_spec.BoundedArraySpec(
          shape=(self._num_slots,),
          dtype=np.int32,
          minimum=0,
          maximum=num_items - 1,
          name="action",
      )
      reward_spec = array_spec.ArraySpec(
          shape=[self._num_slots], dtype=np.float32, name="score_vector"
      )
  
      super(ExplicitPositionalBiasRankingEnvironment, self).__init__(
          observation_spec, action_spec, reward_spec, name=name
      )
  
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 1 to create a new ExplicitPositionalBiasRankingEnvironment object from inherited base classes: bandit_py_environment with example: obj = ExplicitPositionalBiasRankingEnvironment(global_sampling_fn, item_sampling_fn, relevance_fn, num_items, observation_probs, batch_size, name)