class_docstr: .. figure:: https://3qeqpr26caki16dnhd19sv6by6v-wpengine.netdna-ssl.com/wp-content/uploads/2017/08/
      Sample-of-Images-from-the-ImageNet-Dataset-used-in-the-ILSVRC-Challenge.png
      :width: 400
      :alt: Imagenet
  Specs:
      - 1000 classes
      - Each image is (3 x varies x varies) (here we default to 3 x 224 x 224)
  Imagenet train, val and test dataloaders.
  The train set is the imagenet train.
  The val set is taken from the train set with `num_imgs_per_val_class` images per class.
  For example if `num_imgs_per_val_class=2` then there will be 2,000 images in the validation set.
  The test set is the official imagenet validation set.
   Example::
      from pl_bolts.datamodules import ImagenetDataModule
      dm = ImagenetDataModule(IMAGENET_PATH)
      model = LitModel()
      Trainer().fit(model, datamodule=dm)
class_docstr_tok: ["..","figure",":",":","https",":","\/\/3qeqpr26caki16dnhd19sv6by6v-wpengine.netdna-ssl.com\/wp-content\/uploads\/2017\/08\/","Sample-of-Images-from-the-ImageNet-Dataset-used-in-the-ILSVRC-Challenge.png",":","width",":","400",":","alt",":","Imagenet","Specs",":","-","1000","classes","-","Each","image","is","(","3","x","varies","x","varies",")","(","here","we","default","to","3","x","224","x","224",")","Imagenet","train",",","val","and","test","dataloaders",".","The","train","set","is","the","imagenet","train",".","The","val","set","is","taken","from","the","train","set","with","`","num_imgs_per_val_class","`","images","per","class",".","For","example","if","`","num_imgs_per_val_class=2","`","then","there","will","be","2,000","images","in","the","validation","set",".","The","test","set","is","the","official","imagenet","validation","set",".","Example",":",":","from","pl_bolts.datamodules","import","ImagenetDataModule","dm","=","ImagenetDataModule","(","IMAGENET_PATH",")","model","=","LitModel","(",")","Trainer","(",")",".fit","(","model",",","datamodule=dm",")"]
docstr: Args:
      data_dir: path to the imagenet dataset file
      num_imgs_per_val_class: how many images per class for the validation set
      image_size: final image size
      num_workers: how many data workers
      batch_size: batch_size
      shuffle: If true shuffles the data every epoch
      pin_memory: If true, the data loader will copy Tensors into CUDA pinned memory before
                  returning them
      drop_last: If true drops the last incomplete batch
docstr_tok: ["Args",":","data_dir",":","path","to","the","imagenet","dataset","file","num_imgs_per_val_class",":","how","many","images","per","class","for","the","validation","set","image_size",":","final","image","size","num_workers",":","how","many","data","workers","batch_size",":","batch_size","shuffle",":","If","true","shuffles","the","data","every","epoch","pin_memory",":","If","true",",","the","data","loader","will","copy","Tensors","into","CUDA","pinned","memory","before","returning","them","drop_last",":","If","true","drops","the","last","incomplete","batch"]
code: def __init__(
      self,
      data_dir: str,
      image_size: int = 224,
      train_transforms=None,
      val_transforms=None,
      test_transforms=None,
      mixup: Optional[Callable] = None,
      num_aug_repeats: int = 0,
      num_workers: int = 0,
      batch_size: int = 32,
      batch_size_eval: Optional[int] = None,
      shuffle: bool = True,
      pin_memory: bool = True,
      drop_last: bool = False,
      *args: Any,
      **kwargs: Any,
  ) -> None:
      """
      Args:
          data_dir: path to the imagenet dataset file
          num_imgs_per_val_class: how many images per class for the validation set
          image_size: final image size
          num_workers: how many data workers
          batch_size: batch_size
          shuffle: If true shuffles the data every epoch
          pin_memory: If true, the data loader will copy Tensors into CUDA pinned memory before
                      returning them
          drop_last: If true drops the last incomplete batch
      """
      super().__init__(*args, **kwargs)
  
      self.image_size = image_size
      self.train_transforms = train_transforms
      self.val_transforms = val_transforms
      self.test_transforms = test_transforms
      self.mixup = mixup
      self.num_aug_repeats = num_aug_repeats
      self.dims = (3, self.image_size, self.image_size)
      self.data_dir = Path(data_dir).expanduser()
      self.num_workers = num_workers
      self.batch_size = batch_size
      self.batch_size_eval = (
          batch_size_eval
          if batch_size_eval is not None
          else self.batch_size
      )
      self.shuffle = shuffle
      self.pin_memory = pin_memory
      self.drop_last = drop_last
  
imports: import os
  from pathlib import Path
  from typing import Any, List, Union, Callable, Optional
  from torch.utils.data import Dataset, DataLoader
  from torch.utils.data.dataloader import default_collate
  from torch.utils.data.distributed import DistributedSampler
  from pytorch_lightning import LightningDataModule
  from torchvision import transforms
  from torchvision.datasets import ImageFolder
label_desc: Use image node_id 1 to create a new ImagenetDataModule object from inherited base classes: LightningDataModule with example: obj = ImagenetDataModule(data_dir, image_size, train_transforms, val_transforms, test_transforms, mixup, num_aug_repeats, num_workers, batch_size, batch_size_eval, shuffle, pin_memory, drop_last)