code: def apply_transforms(image, size=224):
      """Transforms a PIL image to torch.Tensor.
  
      Applies a series of tranformations on PIL image including a conversion
      to a tensor. The returned tensor has a shape of :math:`(N, C, H, W)` and
      is ready to be used as an input to neural networks.
  
      First the image is resized to 256, then cropped to 224. The `means` and
      `stds` for normalisation are taken from numbers used in ImageNet, as
      currently developing the package for visualizing pre-trained models.
  
      The plan is to to expand this to handle custom size/mean/std.
  
      Args:
          image (PIL.Image.Image or numpy array)
          size (int, optional, default=224): Desired size (width/height) of the
              output tensor
  
      Shape:
          Input: :math:`(C, H, W)` for numpy array
          Output: :math:`(N, C, H, W)`
  
      Returns:
          torch.Tensor (torch.float32): Transformed image tensor
  
      Note:
          Symbols used to describe dimensions:
              - N: number of images in a batch
              - C: number of channels
              - H: height of the image
              - W: width of the image
  
      """
  
      if not isinstance(image, Image.Image):
          image = F.to_pil_image(image)
  
      means = [0.485, 0.456, 0.406]
      stds = [0.229, 0.224, 0.225]
  
      transform = transforms.Compose(
          [
              transforms.Resize(size),
              transforms.CenterCrop(size),
              transforms.ToTensor(),
              transforms.Normalize(means, stds),
          ]
      )
  
      tensor = transform(image).unsqueeze(0)
  
      tensor.requires_grad = True
  
      return tensor
  
file_path: flashtorch/flashtorch/utils/__init__.py
imports: from PIL import Image
  import torchvision.transforms
  import torchvision.transforms.functional
  from .imagenet import *
label_desc: Use image node_id 2 for calling a global function with example usage: apply_transforms(image, size) and returns: tensor