class_docstr: Convert a ``PIL Image`` to ``numpy.ndarray``.
  
  Converts a PIL Image (H x W x C) in the range [0, 255] to a ``numpy.array`` of shape 
  (C x H x W) in the range [0.0, 1.0]
  if the PIL Image belongs to one of the modes (L, LA, P, I, F, RGB, YCbCr, RGBA, CMYK, 1).
  
  In the other cases, tensors are returned without scaling.
  
  .. note::
      Because the input image is scaled to [0.0, 1.0], this transformation should not be used when
      transforming target image masks. 
docstr: Args:
      pic (PIL Image): Image to be converted to array.
  
  Returns:
      Array: Converted image.
docstr_tok: ["Args",":","pic","(","PIL","Image",")",":","Image","to","be","converted","to","array",".","Returns",":","Array",":","Converted","image","."]
code: def forward(self, pic):
      """
      Args:
          pic (PIL Image): Image to be converted to array.
  
      Returns:
          Array: Converted image.
      """
      if not isinstance(pic, Image.Image):
          raise TypeError(
              "pic should be PIL Image. Got {}".format(type(pic))
          )
  
      # Handle PIL Image
      mode_to_nptype = {
          "I": np.int32,
          "I;16": np.int16,
          "F": np.float32,
      }
      img = np.array(
          pic, mode_to_nptype.get(pic.mode, np.uint8), copy=True
      )
  
      if pic.mode == "1":
          img = 255 * img
  
      # Put it from HWC to CHW format
      img = np.transpose(img, (2, 0, 1))
  
      if img.dtype == np.uint8:
          return np.array(np.float32(img) / 255.0, dtype=np.float)
      else:
          return np.float(img)
  
file_path: singa/examples/demos/Classification/BloodMnist/transforms.py
imports: import numpy
  from PIL import Image
label_desc: Use image node_id 1 for calling the ToTensor obj's underlying member method code with example usage: obj.forward(pic) and returns: np, np