code: def patches_from_image(img, p_size=512, p_overlap=64, p_max=800):
      w, h = img.shape[:2]
      patches = []
      if w > p_max and h > p_max:
          w1 = list(
              np.arange(0, w - p_size, p_size - p_overlap, dtype=np.int)
          )
          h1 = list(
              np.arange(0, h - p_size, p_size - p_overlap, dtype=np.int)
          )
          w1.append(w - p_size)
          h1.append(h - p_size)
          #        print(w1)
          #        print(h1)
          for i in w1:
              for j in h1:
                  patches.append(img[i : i + p_size, j : j + p_size, :])
      else:
          patches.append(img)
  
      return patches
  
imports: import os
  import math
  import random
  import numpy
  import torch
  import cv2
  from torchvision.utils import make_grid
  from datetime import datetime
label_desc: Use image node_id 7 for calling a global function with example usage: patches_from_image(img, p_size, p_overlap, p_max) and returns: patches