code: def get_valid_indices(
      H: int, W: int, patch_size: int, random_overlap: int = 0
  ):
      vih = torch.arange(
          random_overlap,
          H - patch_size - random_overlap + 1,
          patch_size,
      )
      viw = torch.arange(
          random_overlap,
          W - patch_size - random_overlap + 1,
          patch_size,
      )
      if random_overlap > 0:
          rih = torch.randint_like(vih, -random_overlap, random_overlap)
          riw = torch.randint_like(viw, -random_overlap, random_overlap)
          vih += rih
          viw += riw
      vi = torch.stack(torch.meshgrid(vih, viw)).view(2, -1).t()
      return vi
  
imports: from typing import Callable, Dict
  import torch
  from torch.utils.data import Dataset
  import torchvision.transforms.functional
  from torchvision import transforms
  import pytorch_lightning
  from collections.abc import Iterable
  from pathlib import Path
  from PIL import Image
  from typing import Tuple
label_desc: Use image node_id 5 for calling a global function with example usage: get_valid_indices(H, W, patch_size, random_overlap) and returns: vi