code: def prepare_cuts(
      iters=4,
      batch_size=16,
      input_size=None,
      output_size=None,
      even_paste_count=False,
      no_intersections=False,
      full_input=False,
      in_anchor_top_left=False,
      in_anchor_range=None,
      out_anchor_top_left=False,
      out_anchor_range=None,
      out_of_bounds_count=0,
  ):
      # Those two will not work together
      assert out_of_bounds_count == 0 or not no_intersections
  
      in_idx_l = [
          np.zeros(shape=(0,), dtype=np.int32)
          for _ in range(batch_size)
      ]
      in_anchors_l = [
          np.zeros(shape=(0, 2), dtype=np.int32)
          for _ in range(batch_size)
      ]
      shapes_l = [
          np.zeros(shape=(0, 2), dtype=np.int32)
          for _ in range(batch_size)
      ]
      out_anchors_l = [
          np.zeros(shape=(0, 2), dtype=np.int32)
          for _ in range(batch_size)
      ]
      assert len(input_size) == len(output_size)
      dim = len(input_size)
      for i in range(batch_size):
          for j in range(iters):
              while True:
                  in_idx = np.int32(np.random.randint(batch_size))
                  out_idx = np.int32(
                      i
                      if even_paste_count
                      else np.random.randint(batch_size)
                  )
                  shape = (
                      [
                          np.int32(
                              np.random.randint(
                                  min(input_size[i], output_size[i])
                                  // (iters if no_intersections else 1)
                              )
                              + 1
                          )
                          for i in range(dim)
                      ]
                      if not full_input
                      else input_size
                  )
  
                  if in_anchor_top_left:
                      in_anchor = [0] * dim
                  elif in_anchor_range is not None:
                      in_anchor = [
                          np.int32(
                              np.random.randint(
                                  in_anchor_range[0][i],
                                  in_anchor_range[1][i],
                              )
                          )
                          for i in range(dim)
                      ]
                      if full_input:
                          shape = [
                              np.int32(input_size[i] - in_anchor[i])
                              for i in range(dim)
                          ]
                  else:
                      in_anchor = [
                          np.int32(
                              np.random.randint(
                                  input_size[i] - shape[i] + 1
                              )
                          )
                          for i in range(dim)
                      ]
  
                  if out_anchor_top_left:
                      out_anchor = [0] * dim
                  elif out_anchor_range is not None:
                      out_anchor = [
                          np.int32(
                              np.random.randint(
                                  out_anchor_range[0][i],
                                  out_anchor_range[1][i],
                              )
                          )
                          for i in range(dim)
                      ]
                  else:
                      out_anchor = [
                          np.int32(
                              np.random.randint(
                                  output_size[i] - shape[i] + 1
                              )
                          )
                          for i in range(dim)
                      ]
  
                  if no_intersections:
                      is_ok = True
                      for k in range(len(in_idx_l[out_idx])):
                          if intersects(
                              out_anchors_l[out_idx][k],
                              shapes_l[out_idx][k],
                              out_anchor,
                              shape,
                          ):
                              is_ok = False
                              break
                      if not is_ok:
                          continue
                      break
                  break
  
              if DEBUG_LVL >= 1:
                  print(
                      f"""in_idx: {in_idx}, out_idx: {out_idx}, in_anchor: {
                  in_anchor}, in_shape: {shape}, out_anchor: {out_anchor}"""
                  )
  
              in_idx_l[out_idx] = np.append(
                  in_idx_l[out_idx], [in_idx], axis=0
              )
              in_anchors_l[out_idx] = np.append(
                  in_anchors_l[out_idx], [in_anchor], axis=0
              )
              shapes_l[out_idx] = np.append(
                  shapes_l[out_idx], [shape], axis=0
              )
              out_anchors_l[out_idx] = np.append(
                  out_anchors_l[out_idx], [out_anchor], axis=0
              )
      for i in range(out_of_bounds_count):
          clip_out_idx = np.random.randint(batch_size)
          while len(in_idx_l[clip_out_idx]) == 0:
              clip_out_idx = np.random.randint(batch_size)
          clip_in_idx = np.random.randint(len(in_idx_l[clip_out_idx]))
          change_in = np.random.randint(2) == 0
          below_zero = np.random.randint(2) == 0
          change_dim_idx = np.random.randint(dim)
          if below_zero:
              anchors = in_anchors_l if change_in else out_anchors_l
              anchors[clip_out_idx][clip_in_idx][
                  change_dim_idx
              ] = np.int32(np.random.randint(-5, 0))
          else:
              anchors = in_anchors_l if change_in else out_anchors_l
              size = input_size if change_in else output_size
              anchors[clip_out_idx][clip_in_idx][
                  change_dim_idx
              ] = np.int32(
                  size[change_dim_idx]
                  - shapes_l[clip_out_idx][clip_in_idx][change_dim_idx]
                  + np.random.randint(5)
                  + 1
              )
  
      return in_idx_l, in_anchors_l, shapes_l, out_anchors_l
  
file_path: DALI/dali/test/python/operator_1/test_multipaste.py
imports: from nvidia.dali.pipeline import Pipeline
  import nvidia.dali.fn
  import nvidia.dali.types
  import numpy
  import os
  from test_utils import get_dali_extra_path
label_desc: Use image node_id 2 for calling a global function with example usage: prepare_cuts(iters, batch_size, input_size, output_size, even_paste_count, no_intersections, full_input, in_anchor_top_left, in_anchor_range, out_anchor_top_left, out_anchor_range, out_of_bounds_count) and returns: in_idx_l,  in_anchors_l,  shapes_l,  out_anchors_l