docstr: Test propensity computation of seq2slate net
docstr_tok: ["Test","propensity","computation","of","seq2slate","net"]
code: def test_seq2slate_transformer_propensity_computation(
      self, output_arch, temperature
  ):
      """
      Test propensity computation of seq2slate net
      """
      candidate_num = 4
      candidate_dim = 2
      hidden_size = 32
      all_perm = torch.tensor(
          list(permutations(torch.arange(candidate_num), candidate_num))
      )
      batch_size = len(all_perm)
      device = torch.device("cpu")
  
      seq2slate_net = create_seq2slate_net(
          MODEL_TRANSFORMER,
          candidate_num,
          candidate_dim,
          hidden_size,
          output_arch,
          temperature,
          device,
      )
      batch = create_batch(
          batch_size,
          candidate_num,
          candidate_dim,
          device,
          ON_POLICY,
          diverse_input=False,
      )
      batch = rlt.PreprocessedRankingInput.from_input(
          state=batch.state.float_features,
          candidates=batch.src_seq.float_features,
          device=device,
          action=all_perm,
      )
      per_symbol_log_prob = seq2slate_net(
          batch, mode=Seq2SlateMode.PER_SYMBOL_LOG_PROB_DIST_MODE
      ).log_probs
      per_seq_log_prob = seq2slate_net(
          batch, mode=Seq2SlateMode.PER_SEQ_LOG_PROB_MODE
      ).log_probs
      per_seq_log_prob_computed = per_symbol_to_per_seq_log_probs(
          per_symbol_log_prob, all_perm + 2
      )
      # probabilities of two modes should match
      np.testing.assert_allclose(
          per_seq_log_prob, per_seq_log_prob_computed, atol=0.00001
      )
      # probabilities of all possible permutations should sum up to 1
      np.testing.assert_allclose(
          torch.sum(torch.exp(per_seq_log_prob)), 1.0, atol=0.00001
      )
  
imports: import itertools
  import logging
  import random
  import unittest
  from collections import defaultdict
  from itertools import permutations
  import numpy
  import pytest
  import reagent.core.types
  import torch
  import torch.nn.functional
  from parameterized import parameterized
  from reagent.model_utils.seq2slate_utils import DECODER_START_SYMBOL, mask_logits_by_idx, per_symbol_to_per_seq_log_probs, per_symbol_to_per_seq_probs, pytorch_decoder_mask, Seq2SlateMode, Seq2SlateOutputArch, subsequent_mask
  from reagent.test.ranking.seq2slate_utils import create_batch, create_seq2slate_net, MODEL_TRANSFORMER, ON_POLICY, rank_on_policy, run_seq2slate_tsp
label_desc: Use image node_id 7 for calling the TestSeq2SlateOnPolicy obj's underlying member method code with example usage: obj.test_seq2slate_transformer_propensity_computation(output_arch, temperature) without return types