code: def get_per_slate_q_values(policy, score_no_click, scores, q_values):
      indices = policy.slates_indices.to(scores.device)
      A, S = policy.slates.shape
      slate_q_values = torch.take_along_dim(
          scores * q_values, indices, dim=1
      ).reshape([-1, A, S])
      slate_scores = torch.take_along_dim(
          scores, indices, dim=1
      ).reshape([-1, A, S])
      slate_normalizer = torch.sum(
          slate_scores, dim=2
      ) + score_no_click.unsqueeze(1)
  
      slate_q_values = slate_q_values / slate_normalizer.unsqueeze(2)
      slate_sum_q_values = torch.sum(slate_q_values, dim=2)
      return slate_sum_q_values
  
imports: import logging
  from typing import Dict, Tuple, Type
  import gymnasium
  import numpy
  from rllib_slate_q.slate_q.slateq_torch_model import SlateQTorchModel
  from ray.rllib.models.modelv2 import ModelV2
  from ray.rllib.models.torch.torch_action_dist import TorchCategorical, TorchDistributionWrapper
  from ray.rllib.policy.policy import Policy
  from ray.rllib.policy.policy_template import build_policy_class
  from ray.rllib.policy.sample_batch import SampleBatch
  from ray.rllib.policy.torch_mixins import TargetNetworkMixin
  from ray.rllib.utils.framework import try_import_torch
  from ray.rllib.utils.torch_utils import apply_grad_clipping, concat_multi_gpu_td_errors, convert_to_torch_tensor, huber_loss
  from ray.rllib.utils.typing import AlgorithmConfigDict, TensorType
label_desc: Use image node_id 5 for calling a global function with example usage: get_per_slate_q_values(policy, score_no_click, scores, q_values) and returns: slate_sum_q_values