class_docstr: Randomly crop images and make sure to contain at least one intact
  instance.
code: def sample_valid_start_end(
      self, valid_array, min_len, max_start, min_end
  ):
      assert isinstance(min_len, int)
      assert len(valid_array) > min_len
  
      start_array = valid_array.copy()
      max_start = min(len(start_array) - min_len, max_start)
      start_array[max_start:] = 0
      start_array[0] = 1
      diff_array = np.hstack([0, start_array]) - np.hstack(
          [start_array, 0]
      )
      region_starts = np.where(diff_array < 0)[0]
      region_ends = np.where(diff_array > 0)[0]
      region_ind = np.random.randint(0, len(region_starts))
      start = np.random.randint(
          region_starts[region_ind], region_ends[region_ind]
      )
  
      end_array = valid_array.copy()
      min_end = max(start + min_len, min_end)
      end_array[:min_end] = 0
      end_array[-1] = 1
      diff_array = np.hstack([0, end_array]) - np.hstack([end_array, 0])
      region_starts = np.where(diff_array < 0)[0]
      region_ends = np.where(diff_array > 0)[0]
      region_ind = np.random.randint(0, len(region_starts))
      end = np.random.randint(
          region_starts[region_ind], region_ends[region_ind]
      )
      return start, end
  
imports: import numpy
  from PIL import Image, ImageDraw
  import cv2
  from shapely.geometry import Polygon
  import math
  from ppocr.utils.poly_nms import poly_intersection
label_desc: Use image node_id 2 for calling the RandomCropPolyInstances obj's underlying member method code with example usage: obj.sample_valid_start_end(valid_array, min_len, max_start, min_end) and returns: start,  end