code: def _process_item(
      d,
      nuclei_id_key,
      mask_value_key,
      image_id,
      nuclei_id,
      images_dir,
      labels_dir,
      image_np,
      instances,
      instance_idx,
      crop_size,
      image_size,
      class_id,
      centroid,
      min_area,
      min_distance,
  ):
      bbox = compute_bbox(crop_size, centroid, image_size)
  
      cropped_label_np = instances[bbox[0] : bbox[2], bbox[1] : bbox[3]]
      cropped_label_np = np.array(cropped_label_np)
  
      signal = np.where(cropped_label_np == instance_idx, class_id, 0)
      if np.count_nonzero(signal) < min_area:
          return None
  
      x, y = centroid
      if (
          x < min_distance
          or y < min_distance
          or (image_size[0] - x) < min_distance
          or (image_size[1] - y < min_distance)
      ):
          return None
  
      others = np.where(
          np.logical_and(
              cropped_label_np > 0, cropped_label_np != instance_idx
          ),
          255,
          0,
      )
      cropped_label_np = signal + others
      cropped_label = Image.fromarray(
          cropped_label_np.astype(np.uint8), None
      )
  
      cropped_image_np = image_np[
          bbox[0] : bbox[2], bbox[1] : bbox[3], :
      ]
      cropped_image = Image.fromarray(cropped_image_np, "RGB")
  
      # # For Debug Only (draw polyline for this and other nuclei cells)
      # from PIL import ImageDraw
      # for mask, color in zip([signal, others], ['green', 'blue']):
      #     mask[mask > 0] = 1
      #     contours, _ = cv2.findContours(mask.astype(np.uint8), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
      #     for contour in contours:
      #         if len(contour) < 3:
      #             continue
      #         contour = np.squeeze(contour)
      #         coords = contour.astype(int).tolist()
      #         coords = [tuple(c) for c in coords]
      #         ImageDraw.Draw(cropped_image).polygon(coords, outline=color)
  
      filename = (
          f"{image_id}_{class_id}_{str(instance_idx).zfill(4)}.png"
      )
      image_file = os.path.join(images_dir, filename)
      label_file = os.path.join(labels_dir, filename)
  
      cropped_image.save(image_file)
      cropped_label.save(label_file)
  
      item = copy.deepcopy(d)
      item[nuclei_id_key] = nuclei_id
      item[mask_value_key] = class_id
      item["image"] = image_file
      item["label"] = label_file
      return item
  
imports: import copy
  import logging
  import os
  import random
  import shutil
  import xml.etree.ElementTree
  from io import BytesIO
  from math import ceil
  import cv2
  import numpy
  import openslide
  import scipy
  from PIL import Image
  from tqdm import tqdm
  from monailabel.datastore.dsa import DSADatastore
  from monailabel.datastore.local import LocalDatastore
  from monailabel.interfaces.datastore import Datastore
  from monailabel.utils.others.generic import get_basename, get_basename_no_ext, is_openslide_supported
label_desc: Use image node_id 7 for calling a global function with example usage: _process_item(d, nuclei_id_key, mask_value_key, image_id, nuclei_id, images_dir, labels_dir, image_np, instances, instance_idx, crop_size, image_size, class_id, centroid, min_area, min_distance) and returns: item, None, None