code: def partition(k: int, ls: List[T]) -> List[List[T]]:
      assert k > 0
      assert ls
  
      n = len(ls)
      parts = [(n - i + k - 1) // k for i in range(k)]
      assert sum(parts) == n
      assert max(parts) - min(parts) <= 1
  
      out = []
      start = 0
      for part in parts:
          out.append(ls[start : start + part])
          start += part
      return out
  
imports: import os
  import random
  import subprocess
  from typing import List, TypeVar
label_desc: Use image node_id 1 for calling a global function with example usage: partition(k, ls) and returns: out