code: def swap_dist(idx: List[int]):
      """
      A distance which measures how many swaps the prod
      ordering needs to get to idx
  
      Examples:
      swap_dist([0, 1, 2, 4]) = 1
      swap_dist([0, 1, 5, 2]) = 3
      """
      assert type(idx) is list
      return swap_dist_in_slate(idx) + swap_dist_out_slate(idx)
  
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 4 for calling a global function with example usage: swap_dist(idx) and returns: unknown