class_docstr: Tile Image into (non)overlapping Patches. Images are tiled in order to efficiently process large images.
  
  Args:
      tile_size: Tile dimension for each patch
      stride: Stride length between patches
      remove_border_count: Number of border pixels to be removed from tile before untiling
      mode: Upscaling mode for image resize.Supported formats: padding, interpolation
  
  Examples:
      >>> import torch
      >>> from torchvision import transforms
      >>> from skimage.data import camera
      >>> tiler = Tiler(tile_size=256,stride=128)
      >>> image = transforms.ToTensor()(camera())
      >>> tiles = tiler.tile(image)
      >>> image.shape, tiles.shape
      (torch.Size([3, 512, 512]), torch.Size([9, 3, 256, 256]))
  
      >>> # Perform your operations on the tiles.
  
      >>> # Untile the patches to reconstruct the image
      >>> reconstructed_image = tiler.untile(tiles)
      >>> reconstructed_image.shape
      torch.Size([1, 3, 512, 512])
docstr: Unfolds tensor into tiles.
  
  This is the core function to perform tiling operation.
  
  Args:
      tensor: Input tensor from which tiles are generated.
  
  Returns: Generated tiles
docstr_tok: ["Unfolds","tensor","into","tiles",".","This","is","the","core","function","to","perform","tiling","operation",".","Args",":","tensor",":","Input","tensor","from","which","tiles","are","generated",".","Returns",":","Generated","tiles"]
code: def __unfold(self, tensor: Tensor) -> Tensor:
      """Unfolds tensor into tiles.
  
      This is the core function to perform tiling operation.
  
      Args:
          tensor: Input tensor from which tiles are generated.
  
      Returns: Generated tiles
      """
  
      # identify device type based on input tensor
      device = tensor.device
  
      # extract and calculate parameters
      batch, channels, image_h, image_w = tensor.shape
  
      self.num_patches_h = (
          int((image_h - self.tile_size_h) / self.stride_h) + 1
      )
      self.num_patches_w = (
          int((image_w - self.tile_size_w) / self.stride_w) + 1
      )
  
      # create an empty torch tensor for output
      tiles = torch.zeros(
          (
              self.num_patches_h,
              self.num_patches_w,
              batch,
              channels,
              self.tile_size_h,
              self.tile_size_w,
          ),
          device=device,
      )
  
      # fill-in output tensor with spatial patches extracted from the image
      for (tile_i, tile_j), (loc_i, loc_j) in zip(
          product(range(self.num_patches_h), range(self.num_patches_w)),
          product(
              range(0, image_h - self.tile_size_h + 1, self.stride_h),
              range(0, image_w - self.tile_size_w + 1, self.stride_w),
          ),
      ):
          tiles[tile_i, tile_j, :] = tensor[
              :,
              :,
              loc_i : (loc_i + self.tile_size_h),
              loc_j : (loc_j + self.tile_size_w),
          ]
  
      # rearrange the tiles in order [tile_count * batch, channels, tile_height, tile_width]
      tiles = tiles.permute(2, 0, 1, 3, 4, 5)
      tiles = tiles.contiguous().view(
          -1, channels, self.tile_size_h, self.tile_size_w
      )
  
      return tiles
  
imports: from __future__ import annotations
  from enum import Enum
  from itertools import product
  from math import ceil
  from typing import Sequence
  import torch
  import torchvision.transforms
  from torch import Tensor
  from torch.nn import functional
label_desc: Use image node_id 4 for calling the Tiler obj's underlying member method code with example usage: obj.__unfold(tensor) and returns: tiles