code: def make_random_rectangle_mask(
      shape,
      margin=10,
      bbox_min_size=30,
      bbox_max_size=100,
      min_times=0,
      max_times=3,
  ):
      height, width = shape
      mask = np.zeros((height, width), np.float32)
      bbox_max_size = min(
          bbox_max_size, height - margin * 2, width - margin * 2
      )
      times = np.random.randint(min_times, max_times + 1)
      if bbox_min_size >= bbox_max_size:
          bbox_min_size = bbox_max_size - 1
      for i in range(times):
          box_width = np.random.randint(bbox_min_size, bbox_max_size)
          box_height = np.random.randint(bbox_min_size, bbox_max_size)
          start_x = np.random.randint(
              margin, width - margin - box_width + 1
          )
          start_y = np.random.randint(
              margin, height - margin - box_height + 1
          )
          mask[
              start_y : start_y + box_height,
              start_x : start_x + box_width,
          ] = 1
      return mask[..., None]
  
imports: import math
  import random
  import hashlib
  import logging
  from enum import Enum
  import cv2
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: make_random_rectangle_mask(shape, margin, bbox_min_size, bbox_max_size, min_times, max_times) and returns: mask