code: def padded_to_list(
      x: torch.Tensor,
      split_size: Union[
          Sequence[int], Sequence[Sequence[int]], None
      ] = None,
  ):
      r"""
      Transforms a padded tensor of shape (N, S_1, S_2, ..., S_D) into a list
      of N tensors of shape:
      - (Si_1, Si_2, ..., Si_D) where (Si_1, Si_2, ..., Si_D) is specified in split_size(i)
      - or (S_1, S_2, ..., S_D) if split_size is None
      - or (Si_1, S_2, ..., S_D) if split_size(i) is an integer.
  
      Args:
        x: tensor
        split_size: optional 1D or 2D list/tuple of ints defining the number of
          items for each tensor.
  
      Returns:
        x_list: a list of tensors sharing the memory with the input.
      """
      x_list = list(x.unbind(0))
  
      if split_size is None:
          return x_list
  
      N = len(split_size)
      if x.shape[0] != N:
          raise ValueError(
              "Split size must be of same length as inputs first dimension"
          )
  
      for i in range(N):
          if isinstance(split_size[i], int):
              x_list[i] = x_list[i][: split_size[i]]
          else:
              slices = tuple(
                  slice(0, s) for s in split_size[i]
              )  # pyre-ignore
              x_list[i] = x_list[i][slices]
      return x_list
  
imports: from typing import List, Sequence, Tuple, Union
  import torch
label_desc: Use image node_id 2 for calling a global function with example usage: padded_to_list(x, split_size) and returns: x_list, x_list