code: def _region_to_tiles(name, w, h, input_np, tile_size, output, prefix):
      max_w = tile_size[0]
      max_h = tile_size[1]
  
      tiles_i = ceil(w / max_w)  # COL
      tiles_j = ceil(h / max_h)  # ROW
  
      logger.info(
          f"{prefix} => Input: {input_np.shape}; Total Patches to save: {tiles_i * tiles_j}"
      )
      os.makedirs(output, exist_ok=True)
  
      result = {}
      for tj in range(tiles_j):
          for ti in range(tiles_i):
              tw = min(max_w, w - ti * max_w)
              th = min(max_h, h - tj * max_h)
  
              sx = ti * max_w
              sy = tj * max_h
  
              logger.debug(
                  f"{prefix} => Patch/Slice ({tj}, {ti}) => {sx}:{sx + tw}, {sy}:{sy + th}"
              )
              if len(input_np.shape) == 3:
                  region_rgb = input_np[
                      sy : (sy + th), sx : (sx + tw), :
                  ]
                  image_np = np.zeros(
                      (max_h, max_w, 3), dtype=input_np.dtype
                  )
              else:
                  region_rgb = input_np[sy : (sy + th), sx : (sx + tw)]
                  image_np = np.zeros(
                      (max_h, max_w), dtype=input_np.dtype
                  )
              image_np[
                  0 : region_rgb.shape[0], 0 : region_rgb.shape[1]
              ] = region_rgb
  
              logger.debug(
                  f"{prefix} => Patch/Slice ({tj}, {ti}) => Size: {region_rgb.shape} / {input_np.shape}"
              )
              img = Image.fromarray(
                  image_np.astype(np.uint8),
                  "RGB" if len(input_np.shape) == 3 else None,
              )
  
              filename = f"{name}_{tj}x{ti}.png"
              save_path = os.path.join(output, filename)
              img.save(save_path)
              result[filename] = save_path
      logger.debug(
          f"{prefix} => Total {len(result)} Patch(s) are Saved at: {output}"
      )
      return result
  
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 13 for calling a global function with example usage: _region_to_tiles(name, w, h, input_np, tile_size, output, prefix) and returns: result