class_docstr: This is just a wrapper around the default image loader from [torchvision]
  (https://pytorch.org/docs/stable/torchvision/io.html#image).
  
  # Parameters
  
  image_backend : `Optional[str]`, optional (default = `None`)
      Set the image backend. Can be one of `"PIL"` or `"accimage"`.
  resize : `bool`, optional (default = `True`)
      If `True` (the default), images will be resized when necessary according
      to the values of `min_size` and `max_size`.
  normalize: `bool`, optional (default = `True`)
      If `True` (the default), images will be normalized according to the values
      of `pixel_mean` and `pixel_std`.
  min_size : `int`, optional (default = `800`)
      If `resize` is `True`, images smaller than this will be resized up to `min_size`.
  max_size : `int`, optional (default = `1333`)
      If `resize` is `True`, images larger than this will be resized down to `max_size`.
  pixel_mean : `Tuple[float, float, float]`, optional (default = `(0.485, 0.456, 0.406)`)
      Mean values for image normalization. The defaults are reasonable for most models
      from `torchvision`.
  pixel_std : `Tuple[float, float, float]`, optional (default = `(0.229, 0.224, 0.225)`)
      Standard deviation for image normalization. The defaults are reasonable for most
      models from `torchvision`.
  size_divisibility : `int`, optional (default = `32`)
      Same parameter as with the `ImageLoader` base class, but the default here is
      different.
class_docstr_tok: ["This","is","just","a","wrapper","around","the","default","image","loader","from","[","torchvision","]","(","https",":","\/\/pytorch.org\/docs\/stable\/torchvision\/io.html","#","image",")",".","#","Parameters","image_backend",":","`","Optional","[","str","]","`",",","optional","(","default","=","`","None","`",")","Set","the","image","backend",".","Can","be","one","of","`","``","PIL","''","`","or","`","``","accimage","''","`",".","resize",":","`","bool","`",",","optional","(","default","=","`","True","`",")","If","`","True","`","(","the","default",")",",","images","will","be","resized","when","necessary","according","to","the","values","of","`","min_size","`","and","`","max_size","`",".","normalize",":","`","bool","`",",","optional","(","default","=","`","True","`",")","If","`","True","`","(","the","default",")",",","images","will","be","normalized","according","to","the","values","of","`","pixel_mean","`","and","`","pixel_std","`",".","min_size",":","`","int","`",",","optional","(","default","=","`","800","`",")","If","`","resize","`","is","`","True","`",",","images","smaller","than","this","will","be","resized","up","to","`","min_size","`",".","max_size",":","`","int","`",",","optional","(","default","=","`","1333","`",")","If","`","resize","`","is","`","True","`",",","images","larger","than","this","will","be","resized","down","to","`","max_size","`",".","pixel_mean",":","`","Tuple","[","float",",","float",",","float","]","`",",","optional","(","default","=","`","(","0.485",",","0.456",",","0.406",")","`",")","Mean","values","for","image","normalization",".","The","defaults","are","reasonable","for","most","models","from","`","torchvision","`",".","pixel_std",":","`","Tuple","[","float",",","float",",","float","]","`",",","optional","(","default","=","`","(","0.229",",","0.224",",","0.225",")","`",")","Standard","deviation","for","image","normalization",".","The","defaults","are","reasonable","for","most","models","from","`","torchvision","`",".","size_divisibility",":","`","int","`",",","optional","(","default","=","`","32","`",")","Same","parameter","as","with","the","`","ImageLoader","`","base","class",",","but","the","default","here","is","different","."]
code: def load(self, filename: OnePath) -> FloatTensor:
      image = (
          torchvision.io.read_image(filename).float().to(self.device)
          / 256
      )
      if self.normalize:
          mean = torch.as_tensor(
              self.pixel_mean, dtype=image.dtype, device=self.device
          ).view(-1, 1, 1)
          std = torch.as_tensor(
              self.pixel_std, dtype=image.dtype, device=self.device
          ).view(-1, 1, 1)
          image = (image - mean) / std
      if self.resize:
          # Adapted from https://github.com/pytorch/vision/blob/
          # 4521f6d152875974e317fa247a633e9ad1ea05c8/torchvision/models/detection/transform.py#L36.
          min_size = min(image.shape[-2:])
          max_size = max(image.shape[-2:])
          scale_factor = self.min_size / min_size
          if max_size * scale_factor > self.max_size:
              scale_factor = self.max_size / max_size
          image = torch.nn.functional.interpolate(
              image[None],
              scale_factor=scale_factor,
              mode="bilinear",
              recompute_scale_factor=True,
              align_corners=False,
          )[0]
      return image
  
file_path: allennlp/allennlp/data/image_loader.py
imports: from os import PathLike
  from typing import Union, Sequence, Tuple, List, cast
  import torch
  import torchvision
  from torch import FloatTensor, IntTensor
  from allennlp.common.file_utils import cached_path
  from allennlp.common.registrable import Registrable
label_desc: Use image node_id 2 for calling the TorchImageLoader obj's underlying member method code with example usage: obj.load(filename) and returns: image