class_docstr: A class implementing ranking policies in TF Agents.
  
  The ranking policy needs at initialization the number of items per round to
  rank, a scorer network, and a score penalizer function. This function should
  ensure that similar items don't all get high scores and thus a diverse set of
  items is recommended.
  
  In the case the number of items to rank varies from iteration to iteration,
  the observation contains a `num_actions` value, that specifies the number of
  items available. Note that in this case it can happen that the number of
  ranked items is less than the number of slots. Thus, consumers of the output
  of `policy.action` should always use the `num_actions` value to determine what
  part of the output is the action ranking.
  
  If `num_actions` field is not used, the policy is always presented with
  `num_items` many items, which should be greater than or equal to `num_slots`.
code: def _distribution(self, time_step, policy_state):
      observation = time_step.observation
      scores, _ = self._network(
          observation, time_step.step_type, policy_state
      )
      if self._use_num_actions:
          num_actions = time_step.observation[
              bandit_spec_utils.NUM_ACTIONS_FEATURE_KEY
          ]
          masked_scores = tf.where(
              tf.sequence_mask(num_actions, maxlen=self._num_items),
              scores,
              tf.fill(tf.shape(scores), -np.inf),
          )
      else:
          masked_scores = scores
      masked_scores = masked_scores / self._logits_temperature
      return policy_step.PolicyStep(
          self._item_sampler(
              observation[bandit_spec_utils.PER_ARM_FEATURE_KEY],
              self._num_slots,
              masked_scores,
              self._penalty_mixture_coefficient,
          ),
          (),
          # TODO(b/197787556): potentially add other side info tensors
          policy_utils.PolicyInfo(predicted_rewards_mean=scores),
      )
  
imports: from typing import Optional, Sequence, Text
  import numpy
  import tensorflow
  import tensorflow_probability
  from tf_agents.policies import tf_policy
  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.typing import types
label_desc: Use image node_id 3 for calling the RankingPolicy obj's underlying member method code with example usage: obj._distribution(time_step, policy_state) and returns: policy_step