docstr: Args:
      num_samples: Number of images displayed in the grid. Default: ``3``.
      nrow: Number of images displayed in each row of the grid.
          The final grid size is ``(B / nrow, nrow)``. Default: ``8``.
      padding: Amount of padding. Default: ``2``.
      normalize: If ``True``, shift the image to the range (0, 1),
          by the min and max values specified by :attr:`range`. Default: ``False``.
      value_range: Tuple (min, max) where min and max are numbers,
          then these numbers are used to normalize the image. By default, min and max
          are computed from the tensor.
      scale_each: If ``True``, scale each image in the batch of
          images separately rather than the (min, max) over all images. Default: ``False``.
      pad_value: Value for the padded pixels. Default: ``0``.
docstr_tok: ["Args",":","num_samples",":","Number","of","images","displayed","in","the","grid",".","Default",":","``","3","``",".","nrow",":","Number","of","images","displayed","in","each","row","of","the","grid",".","The","final","grid","size","is","``","(","B","\/","nrow",",","nrow",")","``",".","Default",":","``","8","``",".","padding",":","Amount","of","padding",".","Default",":","``","2","``",".","normalize",":","If","``","True","``",",","shift","the","image","to","the","range","(","0",",","1",")",",","by","the","min","and","max","values","specified","by",":","attr",":","`","range","`",".","Default",":","``","False","``",".","value_range",":","Tuple","(","min",",","max",")","where","min","and","max","are","numbers",",","then","these","numbers","are","used","to","normalize","the","image",".","By","default",",","min","and","max","are","computed","from","the","tensor",".","scale_each",":","If","``","True","``",",","scale","each","image","in","the","batch","of","images","separately","rather","than","the","(","min",",","max",")","over","all","images",".","Default",":","``","False","``",".","pad_value",":","Value","for","the","padded","pixels",".","Default",":","``","0","``","."]
code: def __init__(
      self,
      num_samples: int = 3,
      nrow: int = 8,
      padding: int = 2,
      normalize: bool = True,
      value_range: Optional[Tuple[int, int]] = None,
      scale_each: bool = False,
      pad_value: int = 0,
  ) -> None:
      """
      Args:
          num_samples: Number of images displayed in the grid. Default: ``3``.
          nrow: Number of images displayed in each row of the grid.
              The final grid size is ``(B / nrow, nrow)``. Default: ``8``.
          padding: Amount of padding. Default: ``2``.
          normalize: If ``True``, shift the image to the range (0, 1),
              by the min and max values specified by :attr:`range`. Default: ``False``.
          value_range: Tuple (min, max) where min and max are numbers,
              then these numbers are used to normalize the image. By default, min and max
              are computed from the tensor.
          scale_each: If ``True``, scale each image in the batch of
              images separately rather than the (min, max) over all images. Default: ``False``.
          pad_value: Value for the padded pixels. Default: ``0``.
      """
      if not _TORCHVISION_AVAILABLE:  # pragma: no cover
          raise ModuleNotFoundError(
              "You want to use `torchvision` which is not installed yet."
          )
  
      super().__init__()
      self.num_samples = num_samples
      self.nrow = nrow
      self.padding = padding
      self.normalize = normalize
      self.value_range = value_range
      self.scale_each = scale_each
      self.pad_value = pad_value
  
imports: from os import path
  from typing import Optional, Tuple
  import torch
  import torch.nn.functional
  from lightning.pytorch import LightningDataModule, LightningModule, Trainer, callbacks, cli_lightning_logo
  from lightning.pytorch.cli import LightningCLI
  from lightning.pytorch.demos.mnist_datamodule import MNIST
  from lightning.pytorch.utilities import rank_zero_only
  from lightning.pytorch.utilities.imports import _TORCHVISION_AVAILABLE
  from torch import nn
  from torch.utils.data import DataLoader, random_split
label_desc: Use image node_id 1 to create a new ImageSampler object from inherited base classes: callbacks with example: obj = ImageSampler(num_samples, nrow, padding, normalize, value_range, scale_each, pad_value)