code: def iter_patch_position(
      image_size: Sequence[int],
      patch_size: Sequence[int] | int | np.ndarray,
      start_pos: Sequence[int] = (),
      overlap: Sequence[float] | float | Sequence[int] | int = 0.0,
      padded: bool = False,
  ):
      """
      Yield successive tuples of upper left corner of patches of size `patch_size` from an array of dimensions `image_size`.
      The iteration starts from position `start_pos` in the array, or starting at the origin if this isn't provided. Each
      patch is chosen in a contiguous grid using a rwo-major ordering.
  
      Args:
          image_size: dimensions of array to iterate over
          patch_size: size of patches to generate slices for, 0 or None selects whole dimension
          start_pos: starting position in the array, default is 0 for each dimension
          overlap: the amount of overlap of neighboring patches in each dimension.
              Either a float or list of floats between 0.0 and 1.0 to define relative overlap to patch size, or
              an int or list of ints to define number of pixels for overlap.
              If only one float/int number is given, it will be applied to all dimensions. Defaults to 0.0.
          padded: if the image is padded so the patches can go beyond the borders. Defaults to False.
  
      Yields:
          Tuples of positions defining the upper left corner of each patch
      """
  
      # ensure patchSize and startPos are the right length
      ndim = len(image_size)
      patch_size_ = get_valid_patch_size(image_size, patch_size)
      start_pos = ensure_tuple_size(start_pos, ndim)
      overlap = ensure_tuple_rep(overlap, ndim)
  
      # calculate steps, which depends on the amount of overlap
      if isinstance(overlap[0], float):
          steps = tuple(
              round(p * (1.0 - o)) for p, o in zip(patch_size_, overlap)
          )
      else:
          steps = tuple(p - o for p, o in zip(patch_size_, overlap))
  
      # calculate the last starting location (depending on the padding)
      end_pos = (
          image_size
          if padded
          else tuple(
              s - round(p) + 1 for s, p in zip(image_size, patch_size_)
          )
      )
  
      # collect the ranges to step over each dimension
      ranges = starmap(range, zip(start_pos, end_pos, steps))
  
      # choose patches by applying product to the ranges
      return product(*ranges)
  
imports: from __future__ import annotations
  import hashlib
  import json
  import logging
  import math
  import os
  import pickle
  import sys
  from collections import abc, defaultdict
  from collections.abc import Generator, Iterable, Mapping, Sequence, Sized
  from copy import deepcopy
  from functools import reduce
  from itertools import product, starmap, zip_longest
  from pathlib import PurePath
  from typing import Any
  import numpy
  import torch
  from torch.utils.data._utils.collate import default_collate
  from monai import config
  from monai.config.type_definitions import NdarrayOrTensor, NdarrayTensor, PathLike
  from monai.data.meta_obj import MetaObj
  from monai.utils import MAX_SEED, BlendMode, Method, NumpyPadMode, TraceKeys, convert_data_type, convert_to_dst_type, ensure_tuple, ensure_tuple_rep, ensure_tuple_size, fall_back_tuple, first, get_equivalent_dtype, issequenceiterable, look_up_option, optional_import, pytorch_after
label_desc: Use image node_id 4 for calling a global function with example usage: iter_patch_position(image_size, patch_size, start_pos, overlap, padded) and returns: product