code: def tensor_from_pil(
      pil_img: Image, dtype: torch.dtype = torch.float32
  ) -> torch.Tensor:
      """Convert a PIL Image to a PyTorch tensor
  
      Args:
      ----
          pil_img: a PIL image
          dtype: the output tensor data type
  
      Returns:
      -------
          decoded image as tensor
      """
      if dtype == torch.float32:
          img = to_tensor(pil_img)
      else:
          img = tensor_from_numpy(
              np.array(pil_img, np.uint8, copy=True), dtype
          )
  
      return img
  
file_path: doctr/doctr/io/image/pytorch.py
imports: from io import BytesIO
  from typing import Tuple
  import numpy
  import torch
  from PIL import Image
  from torchvision.transforms.functional import to_tensor
  from doctr.utils.common_types import AbstractPath
label_desc: Use image node_id 1 for calling a global function with example usage: tensor_from_pil(pil_img, dtype) and returns: img