code: def swap_dist_in_slate(idx_):
      # Do not want to modify the original list because swap happens in place.
      idx = idx_.copy()
      swapcount = 0
      for j in range(len(idx)):
          for i in range(1, len(idx) - j):
              if idx[i - 1] > idx[i]:
                  swapcount += 1
                  idx[i - 1], idx[i] = idx[i], idx[i - 1]
      return swapcount
  
imports: import logging
  from itertools import permutations
  from typing import List, Optional
  import numpy
  import reagent.core.types
  import torch
  import torch.nn
  from reagent.core.dataclasses import field
  from reagent.core.parameters import Seq2SlateParameters
  from reagent.core.torch_utils import gather
  from reagent.models.seq2slate import BaselineNet, Seq2SlateMode, Seq2SlateTransformerNet
  from reagent.optimizer.union import Optimizer__Union
  from reagent.training.ranking.seq2slate_trainer import Seq2SlateTrainer
label_desc: Use image node_id 2 for calling a global function with example usage: swap_dist_in_slate(idx_) and returns: swapcount