code: def _merge_box_list(
      boxes: list[torch.Tensor], method: str = "pad"
  ) -> tuple[torch.Tensor, list[int]]:
      r"""Merge a list of boxes into one tensor."""
      if not all(
          box.shape[-2:] == torch.Size([4, 2]) and box.dim() == 3
          for box in boxes
      ):
          raise TypeError(
              f"Input boxes must be a list of (N, 4, 2) shaped. Got: {[box.shape for box in boxes]}."
          )
  
      if method == "pad":
          max_N = max(box.shape[0] for box in boxes)
          stats = [max_N - box.shape[0] for box in boxes]
          output = torch.nn.utils.rnn.pad_sequence(
              boxes, batch_first=True
          )
      else:
          raise NotImplementedError(f"`{method}` is not implemented.")
  
      return output, stats
  
imports: from __future__ import annotations
  from typing import Optional, cast
  import torch
  from torch import Size
  from kornia.core import Tensor, stack, zeros
  from kornia.geometry.bbox import validate_bbox
  from kornia.geometry.linalg import transform_points
  from kornia.utils import eye_like
label_desc: Use image node_id 2 for calling a global function with example usage: _merge_box_list(boxes, method) and returns: output,  stats