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: Tiles an input image to either overlapping, non-overlapping or random patches.
  
  Args:
      image: Input image to tile.
  
  Examples:
      >>> from anomalib.pre_processing import Tiler
      >>> tiler = Tiler(tile_size=512,stride=256)
      >>> image = torch.rand(size=(2, 3, 1024, 1024))
      >>> image.shape
      torch.Size([2, 3, 1024, 1024])
      >>> tiles = tiler.tile(image)
      >>> tiles.shape
      torch.Size([18, 3, 512, 512])
  
  Returns:
      Tiles generated from the image.
docstr_tok: ["Tiles","an","input","image","to","either","overlapping",",","non-overlapping","or","random","patches",".","Args",":","image",":","Input","image","to","tile",".","Examples",":",">",">",">","from","anomalib.pre_processing","import","Tiler",">",">",">","tiler","=","Tiler","(","tile_size=512",",","stride=256",")",">",">",">","image","=","torch.rand","(","size=","(","2",",","3",",","1024",",","1024",")",")",">",">",">","image.shape","torch.Size","(","[","2",",","3",",","1024",",","1024","]",")",">",">",">","tiles","=","tiler.tile","(","image",")",">",">",">","tiles.shape","torch.Size","(","[","18",",","3",",","512",",","512","]",")","Returns",":","Tiles","generated","from","the","image","."]
code: def tile(
      self, image: Tensor, use_random_tiling: bool = False
  ) -> Tensor:
      """Tiles an input image to either overlapping, non-overlapping or random patches.
  
      Args:
          image: Input image to tile.
  
      Examples:
          >>> from anomalib.pre_processing import Tiler
          >>> tiler = Tiler(tile_size=512,stride=256)
          >>> image = torch.rand(size=(2, 3, 1024, 1024))
          >>> image.shape
          torch.Size([2, 3, 1024, 1024])
          >>> tiles = tiler.tile(image)
          >>> tiles.shape
          torch.Size([18, 3, 512, 512])
  
      Returns:
          Tiles generated from the image.
      """
      if image.dim() == 3:
          image = image.unsqueeze(0)
  
      (
          self.batch_size,
          self.num_channels,
          self.input_h,
          self.input_w,
      ) = image.shape
  
      if (
          self.input_h < self.tile_size_h
          or self.input_w < self.tile_size_w
      ):
          raise ValueError(
              f"One of the edges of the tile size {self.tile_size_h, self.tile_size_w} "
              "is larger than that of the image {self.input_h, self.input_w}."
          )
  
      self.resized_h, self.resized_w = compute_new_image_size(
          image_size=(self.input_h, self.input_w),
          tile_size=(self.tile_size_h, self.tile_size_w),
          stride=(self.stride_h, self.stride_w),
      )
  
      image = upscale_image(
          image, size=(self.resized_h, self.resized_w), mode=self.mode
      )
  
      if use_random_tiling:
          image_tiles = self.__random_tile(image)
      else:
          image_tiles = self.__unfold(image)
      return image_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 6 for calling the Tiler obj's underlying member method code with example usage: obj.tile(image, use_random_tiling) and returns: image_tiles