code: def apply_permutation(
      tensor: Tensor, permutation: Tensor, dim: int = 1
  ) -> Tensor:
      return tensor.index_select(dim, permutation)
  
imports: import warnings
  from typing import List, Optional, Tuple
  import torch
  from torch import _VF, Tensor
  from torch.nn.utils.rnn import PackedSequence
label_desc: Use image node_id 1 for calling a global function with example usage: apply_permutation(tensor, permutation, dim) and returns: tensor