class_docstr: Mosaic augmentation.
  
  .. image:: https://raw.githubusercontent.com/kornia/data/main/random_mosaic.png
  
  Given a certain number of images, mosaic transform combines them into one output image.
  The output image is composed of the parts from each sub-image. To mess up each image individually,
  referring to :class:`kornia.augmentation.RandomJigsaw`.
  
  The mosaic transform steps are as follows:
  
       1. Concate selected images into a super-image.
       2. Crop out the outcome image according to the top-left corner and crop size.
  
  Args:
      output_size: the output tensor width and height after mosaicing.
      start_ratio_range: top-left (x, y) position for cropping the mosaic images.
      mosaic_grid: the number of images and image arrangement. e.g. (2, 2) means
          each output will mix 4 images in a 2x2 grid.
      min_bbox_size: minimum area of bounding boxes. Default to 0.
      data_keys: the input type sequential for applying augmentations.
          Accepts "input", "image", "mask", "bbox", "bbox_xyxy", "bbox_xywh", "keypoints".
      p: probability of applying the transformation for the whole batch.
      keepdim: whether to keep the output shape the same as input ``True`` or broadcast it
          to the batch form ``False``.
      padding_mode: Type of padding. Should be: constant, reflect, replicate.
      resample: the interpolation mode.
      align_corners: interpolation flag.
      cropping_mode: The used algorithm to crop. ``slice`` will use advanced slicing to extract the tensor based
          on the sampled indices. ``resample`` will use `warp_affine` using the affine transformation
          to extract and resize at once. Use `slice` for efficiency, or `resample` for proper
          differentiability.
  
  Examples:
      >>> mosaic = RandomMosaic((300, 300), data_keys=["input", "bbox_xyxy"])
      >>> boxes = torch.tensor([[
      ...     [70, 5, 150, 100],
      ...     [60, 180, 175, 220],
      ... ]]).repeat(8, 1, 1)
      >>> input = torch.randn(8, 3, 224, 224)
      >>> out = mosaic(input, boxes)
      >>> out[0].shape, out[1].shape
      (torch.Size([8, 3, 300, 300]), torch.Size([8, 8, 4]))
code: def apply_transform_boxes(
      self,
      input: Boxes,
      params: Dict[str, Tensor],
      flags: Dict[str, Any],
  ) -> Boxes:
      to_apply = params["batch_prob"] > 0.5
      src_box = as_tensor(
          params["src"], device=input.device, dtype=input.dtype
      )
      dst_box = as_tensor(
          params["dst"], device=input.device, dtype=input.dtype
      )
      # Boxes is BxNx4x2 only.
      batch_shapes = as_tensor(
          params["batch_shapes"], device=input.device, dtype=input.dtype
      )
      offset = zeros(
          (len(to_apply), 2), device=input.device, dtype=input.dtype
      )  # Bx2
      # NOTE: not a pretty good line I think.
      offset_end = dst_box[0, 2].repeat(input.data.shape[0], 1)
      idx = torch.arange(
          0, input.data.shape[0], device=input.device, dtype=torch.long
      )[to_apply]
  
      maybe_out_boxes: Optional[Boxes] = None
      for i in range(flags["mosaic_grid"][0]):
          for j in range(flags["mosaic_grid"][1]):
              _offset = offset.clone()
              _offset[idx, 0] = (
                  batch_shapes[:, -2] * i - src_box[:, 0, 0]
              )
              _offset[idx, 1] = (
                  batch_shapes[:, -1] * j - src_box[:, 0, 1]
              )
              _box = input.clone()
              _idx = i * flags["mosaic_grid"][1] + j
              _box._data[params["permutation"][:, 0]] = _box._data[
                  params["permutation"][:, _idx]
              ]
              _box.translate(_offset, inplace=True)
              # zero-out unrelated batch elements.
              _box._data[~to_apply] = 0
              if maybe_out_boxes is None:
                  _box._data[~to_apply] = input._data[~to_apply]
                  maybe_out_boxes = _box
              else:
                  KORNIA_UNWRAP(maybe_out_boxes, Boxes).merge(
                      _box, inplace=True
                  )
      out_boxes: Boxes = KORNIA_UNWRAP(maybe_out_boxes, Boxes)
      out_boxes.clamp(offset, offset_end, inplace=True)
      out_boxes.filter_boxes_by_area(
          flags["min_bbox_size"], inplace=True
      )
      return out_boxes
  
imports: from typing import Any, Dict, List, Optional, Tuple, Union
  import torch
  from kornia.augmentation import random_generator
  from kornia.augmentation._2d.mix.base import MixAugmentationBaseV2
  from kornia.constants import DataKey, Resample
  from kornia.core import Tensor, as_tensor, concatenate, pad, zeros
  from kornia.core.check import KORNIA_UNWRAP
  from kornia.geometry.boxes import Boxes
  from kornia.geometry.transform import crop_by_indices, crop_by_transform_mat, get_perspective_transform
  from kornia.utils import eye_like
label_desc: Use image node_id 3 for calling the RandomMosaic obj's underlying member method code with example usage: obj.apply_transform_boxes(input, params, flags) and returns: out_boxes