code: def build_slateq_stats(
      policy: Policy, batch
  ) -> Dict[str, TensorType]:
      stats = {
          "q_values": torch.mean(
              torch.stack(policy.get_tower_stats("q_values"))
          ),
          "q_clicked": torch.mean(
              torch.stack(policy.get_tower_stats("q_clicked"))
          ),
          "scores": torch.mean(
              torch.stack(policy.get_tower_stats("scores"))
          ),
          "score_no_click": torch.mean(
              torch.stack(policy.get_tower_stats("score_no_click"))
          ),
          "slate_q_values": torch.mean(
              torch.stack(policy.get_tower_stats("slate_q_values"))
          ),
          "replay_click_q": torch.mean(
              torch.stack(policy.get_tower_stats("replay_click_q"))
          ),
          "bellman_reward": torch.mean(
              torch.stack(policy.get_tower_stats("bellman_reward"))
          ),
          "next_q_values": torch.mean(
              torch.stack(policy.get_tower_stats("next_q_values"))
          ),
          "target": torch.mean(
              torch.stack(policy.get_tower_stats("target"))
          ),
          "next_q_target_slate": torch.mean(
              torch.stack(policy.get_tower_stats("next_q_target_slate"))
          ),
          "next_q_target_max": torch.mean(
              torch.stack(policy.get_tower_stats("next_q_target_max"))
          ),
          "target_clicked": torch.mean(
              torch.stack(policy.get_tower_stats("target_clicked"))
          ),
          "q_loss": torch.mean(
              torch.stack(policy.get_tower_stats("q_loss"))
          ),
          "mean_actions": torch.mean(
              torch.stack(policy.get_tower_stats("mean_actions"))
          ),
          "choice_loss": torch.mean(
              torch.stack(policy.get_tower_stats("choice_loss"))
          ),
          # "choice_beta": torch.mean(torch.stack(policy.get_tower_stats("choice_beta"))),
          # "choice_score_no_click": torch.mean(
          #    torch.stack(policy.get_tower_stats("choice_score_no_click"))
          # ),
      }
      # model_stats = {
      #    k: torch.mean(var)
      #    for k, var in policy.model.trainable_variables(as_dict=True).items()
      # }
      # stats.update(model_stats)
  
      return stats
  
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 3 for calling a global function with example usage: build_slateq_stats(policy, batch) and returns: stats