code: def testPositionalBiasParams(
      self,
      feedback_model,
      policy_type,
      batch_size,
      global_dim,
      item_dim,
      num_items,
      num_slots,
      positional_bias_type,
      positional_bias_severity,
      positional_bias_positive_only,
  ):
      if not tf.executing_eagerly():
          self.skipTest("Only works in eager mode.")
      obs_spec = bandit_spec_utils.create_per_arm_observation_spec(
          global_dim, item_dim, num_items
      )
      scoring_net = global_and_arm_feature_network.create_feed_forward_common_tower_network(
          obs_spec, (4, 3), (3, 4), (4, 2)
      )
      optimizer = tf.compat.v1.train.GradientDescentOptimizer(
          learning_rate=0.1
      )
      if feedback_model == ranking_agent.FeedbackModel.CASCADING:
          reward_spec = {
              ranking_agent.CHOSEN_INDEX: tensor_spec.BoundedTensorSpec(
                  shape=[], dtype=tf.int32, minimum=0, maximum=num_slots
              ),
              ranking_agent.CHOSEN_VALUE: tensor_spec.TensorSpec(
                  shape=(), dtype=tf.float32
              ),
          }
      elif feedback_model == ranking_agent.FeedbackModel.SCORE_VECTOR:
          reward_spec = tensor_spec.TensorSpec(
              shape=(num_slots,), dtype=tf.float32
          )
      time_step_spec = ts.time_step_spec(
          obs_spec, reward_spec=reward_spec
      )
      action_spec = tensor_spec.BoundedTensorSpec(
          shape=(num_slots,),
          minimum=0,
          maximum=num_items - 1,
          dtype=tf.int32,
      )
  
      agent = ranking_agent.RankingAgent(
          time_step_spec=time_step_spec,
          action_spec=action_spec,
          scoring_network=scoring_net,
          policy_type=policy_type,
          feedback_model=feedback_model,
          positional_bias_type=positional_bias_type,
          positional_bias_severity=positional_bias_severity,
          positional_bias_positive_only=positional_bias_positive_only,
          optimizer=optimizer,
      )
      global_obs = tf.reshape(
          tf.range(batch_size * global_dim, dtype=tf.float32),
          [batch_size, global_dim],
      )
      item_obs = tf.reshape(
          tf.range(batch_size * num_slots * item_dim, dtype=tf.float32),
          [batch_size, num_slots, item_dim],
      )
      observations = {
          bandit_spec_utils.GLOBAL_FEATURE_KEY: global_obs,
          bandit_spec_utils.PER_ARM_FEATURE_KEY: item_obs,
      }
      if feedback_model == ranking_agent.FeedbackModel.CASCADING:
          scores = {
              ranking_agent.CHOSEN_INDEX: tf.range(batch_size) + 1,
              ranking_agent.CHOSEN_VALUE: tf.range(
                  batch_size, dtype=tf.float32
              ),
          }
      elif feedback_model == ranking_agent.FeedbackModel.SCORE_VECTOR:
          scores = tf.reshape(
              tf.range(batch_size * num_slots, dtype=tf.float32),
              shape=[batch_size, num_slots],
          )
      initial_step, final_step = _get_initial_and_final_steps(
          observations, scores
      )
      action_step = policy_step.PolicyStep(
          action=(),
          info=policy_utilities.PolicyInfo(
              predicted_rewards_mean=tf.reshape(
                  tf.range(batch_size * num_slots, dtype=tf.float32),
                  shape=[batch_size, num_slots],
              )
          ),
      )
      experience = _get_experience(
          initial_step, action_step, final_step
      )
      if positional_bias_type == "invalid":
          with self.assertRaisesRegex(
              ValueError, "non-existing bias type"
          ):
              agent.train(experience)
      else:
          agent.train(experience)
          weights = agent._construct_sample_weights(
              scores, observations, None
          )
          self.assertAllEqual(weights.shape, [batch_size, num_slots])
          expected = (
              2**positional_bias_severity
              if positional_bias_type == "base"
              else positional_bias_severity
          )
          self.assertAllClose(weights[-1, 1], expected)
  
file_path: agents/tf_agents/bandits/agents/ranking_agent_test.py
imports: from absl.testing import parameterized
  import tensorflow
  from tf_agents.bandits.agents import ranking_agent
  from tf_agents.bandits.drivers import driver_utils
  from tf_agents.bandits.networks import global_and_arm_feature_network
  from tf_agents.policies import utils
  from tf_agents.specs import bandit_spec_utils
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import policy_step
  from tf_agents.trajectories import time_step
  from tf_agents.utils import test_utils
label_desc: Use image node_id 3 for calling the RankingAgentTest obj's underlying member method code with example usage: obj.testPositionalBiasParams(feedback_model, policy_type, batch_size, global_dim, item_dim, num_items, num_slots, positional_bias_type, positional_bias_severity, positional_bias_positive_only) without return types