code: def rank_on_policy(
      model,
      batch: rlt.PreprocessedRankingInput,
      tgt_seq_len: int,
      greedy: bool,
  ):
      model.eval()
      rank_output = model(
          batch,
          mode=Seq2SlateMode.RANK_MODE,
          tgt_seq_len=tgt_seq_len,
          greedy=greedy,
      )
      ranked_slate_prob = rank_output.ranked_per_seq_probs
      ranked_order = rank_output.ranked_tgt_out_idx - 2
      model.train()
      return ranked_slate_prob, ranked_order
  
imports: import logging
  import math
  import tempfile
  from itertools import permutations
  import pytorch_lightning
  import reagent.core.types
  import torch
  import torch.nn
  from reagent.core.parameters import Seq2SlateParameters
  from reagent.core.parameters_seq2slate import LearningMethod, SimulationParameters
  from reagent.core.torch_utils import gather
  from reagent.model_utils.seq2slate_utils import Seq2SlateOutputArch
  from reagent.models.seq2slate import Seq2SlateMode, Seq2SlateTransformerNet
  from reagent.optimizer.union import Optimizer__Union
  from reagent.training.ranking.seq2slate_sim_trainer import Seq2SlateSimulationTrainer
  from reagent.training.ranking.seq2slate_trainer import Seq2SlateTrainer
  from torch.utils.data import DataLoader
label_desc: Use image node_id 8 for calling a global function with example usage: rank_on_policy(model, batch, tgt_seq_len, greedy) and returns: ranked_slate_prob,  ranked_order