code: def _mosaic(self, images, bboxes, classes):
      def trim_bboxes(bboxes, classes, x0, y0, x1, y1):
          bboxes_ltrb = np.copy(bboxes)
          bboxes_ltrb[:, 0] -= bboxes[:, 2] / 2
          bboxes_ltrb[:, 1] -= bboxes[:, 3] / 2
          bboxes_ltrb[:, 2] += bboxes_ltrb[:, 0]
          bboxes_ltrb[:, 3] += bboxes_ltrb[:, 1]
  
          bboxes_ltrb[:, 0] = np.maximum(x0, bboxes_ltrb[:, 0])
          bboxes_ltrb[:, 1] = np.maximum(y0, bboxes_ltrb[:, 1])
          bboxes_ltrb[:, 2] = np.minimum(x1, bboxes_ltrb[:, 2])
          bboxes_ltrb[:, 3] = np.minimum(y1, bboxes_ltrb[:, 3])
  
          bboxes_xywh = np.copy(bboxes_ltrb)
          bboxes_xywh[:, 2] -= bboxes_xywh[:, 0]
          bboxes_xywh[:, 3] -= bboxes_xywh[:, 1]
          bboxes_xywh[:, 0] += bboxes_xywh[:, 2] / 2
          bboxes_xywh[:, 1] += bboxes_xywh[:, 3] / 2
  
          not_null = np.logical_and(
              bboxes_xywh[:, 2] > 0, bboxes_xywh[:, 3] > 0
          )
          return bboxes_xywh[not_null, :], classes[not_null]
  
      images_out = np.zeros(images.shape)
      bboxes_out = []
      classes_out = []
      for i in range(self._batch_size):
          if random.randrange(2) == 0:
              images_out[i, ...] = images[i, ...]
              bboxes_out.append(bboxes[i])
              classes_out.append(classes[i])
          else:
              ids = np.random.choice(self._batch_size, 4)
              prop_x = np.random.uniform(0.2, 0.8)
              prop_y = np.random.uniform(0.2, 0.8)
              size_x = int(prop_x * self._image_size[0])
              size_y = int(prop_y * self._image_size[1])
              images_out[i, :size_y, :size_x, :] = images[
                  ids[0], :size_y, :size_x, :
              ]
              images_out[i, :size_y, size_x:, :] = images[
                  ids[1], :size_y, size_x:, :
              ]
              images_out[i, size_y:, :size_x, :] = images[
                  ids[2], size_y:, :size_x, :
              ]
              images_out[i, size_y:, size_x:, :] = images[
                  ids[3], size_y:, size_x:, :
              ]
              bboxes00, classes00 = trim_bboxes(
                  bboxes[ids[0]],
                  classes[ids[0]],
                  0.0,
                  0.0,
                  prop_x,
                  prop_y,
              )
              bboxes10, classes10 = trim_bboxes(
                  bboxes[ids[1]],
                  classes[ids[1]],
                  prop_x,
                  0.0,
                  1.0,
                  prop_y,
              )
              bboxes01, classes01 = trim_bboxes(
                  bboxes[ids[2]],
                  classes[ids[2]],
                  0.0,
                  prop_y,
                  prop_x,
                  1.0,
              )
              bboxes11, classes11 = trim_bboxes(
                  bboxes[ids[3]],
                  classes[ids[3]],
                  prop_x,
                  prop_y,
                  1.0,
                  1.0,
              )
              bboxes_out.append(
                  np.concatenate(
                      (bboxes00, bboxes10, bboxes01, bboxes11)
                  )
              )
              classes_out.append(
                  np.concatenate(
                      (classes00, classes10, classes01, classes11)
                  )
              )
  
      return images_out, bboxes_out, classes_out
  
file_path: DALI/docs/examples/use_cases/tensorflow/yolov4/src/np/pipeline.py
imports: from .coco import COCO
  import numpy
  import tensorflow
  import os
  import cv2
  import random
label_desc: Use image node_id 8 for calling the YOLOv4PipelineNumpy obj's underlying member method code with example usage: obj._mosaic(images, bboxes, classes) and returns: images_out,  bboxes_out,  classes_out, bboxes_xywh,  classes