code: def _batch_polygons(polygons: List[Tensor]) -> Tensor:
      r"""Converts a List of variable length polygons into a fixed size tensor.
  
      Works by repeating the last element in the tensor.
      Args:
          polygon: List of variable length polygons of shape [N_1 x 2, N_2 x 2, ..., N_B x 2].
                      B is the batch size,
                      N_i is the number of points,
                      2 is (x, y).
      Returns:
          A fixed size tensor of shape (B, N, 2) where N = max_i(N_i)
      """
      B, N = len(polygons), len(max(polygons, key=len))
      batched_polygons = torch.zeros(
          B, N, 2, dtype=polygons[0].dtype, device=polygons[0].device
      )
      for b, p in enumerate(polygons):
          batched_polygons[b] = (
              torch.cat((p, p[-1:].expand(N - len(p), 2)))
              if len(p) < N
              else p
          )
      return batched_polygons
  
file_path: kornia/kornia/utils/draw.py
imports: from typing import List, Optional, Tuple, Union
  import torch
  from torch import Tensor
  from kornia.core.check import KORNIA_CHECK, KORNIA_CHECK_SHAPE
label_desc: Use image node_id 6 for calling a global function with example usage: _batch_polygons(polygons) and returns: batched_polygons