code: def pil_to_tensor(pic: Any) -> Tensor:
      """Convert a ``PIL Image`` to a tensor of the same type.
      This function does not support torchscript.
  
      See :class:`~torchvision.transforms.PILToTensor` for more details.
  
      .. note::
  
          A deep copy of the underlying array is performed.
  
      Args:
          pic (PIL Image): Image to be converted to tensor.
  
      Returns:
          Tensor: Converted image.
      """
      if not torch.jit.is_scripting() and not torch.jit.is_tracing():
          _log_api_usage_once(pil_to_tensor)
      if not F_pil._is_pil_image(pic):
          raise TypeError(f"pic should be PIL Image. Got {type(pic)}")
  
      if accimage is not None and isinstance(pic, accimage.Image):
          # accimage format is always uint8 internally, so always return uint8 here
          nppic = np.zeros(
              [pic.channels, pic.height, pic.width], dtype=np.uint8
          )
          pic.copyto(nppic)
          return torch.as_tensor(nppic)
  
      # handle PIL Image
      img = torch.as_tensor(np.array(pic, copy=True))
      img = img.view(
          pic.size[1], pic.size[0], F_pil.get_image_num_channels(pic)
      )
      # put it from HWC to CHW format
      img = img.permute((2, 0, 1))
      return img
  
imports: import math
  import numbers
  import sys
  import warnings
  from enum import Enum
  from typing import Any, List, Optional, Tuple, Union
  import numpy
  import torch
  from PIL import Image
  from torch import Tensor
  from ..utils import _log_api_usage_once
  from .None import _functional_pil, _functional_tensor
label_desc: Use image node_id 8 for calling a global function with example usage: pil_to_tensor(pic) and returns: img, torch