code: def read_result_to_ndarray(
      pixels,
      width,
      height,
      metadata,
      grayscale,
      as_uint16,
      num_channels,
  ):
      if metadata["bitdepth"] == 16 and not as_uint16:
          raise ValueError(
              "cannot convert 16bit image to 8bit image."
              " Original range of pixel values is unknown."
          )
  
      output_type = np.uint16 if as_uint16 else np.uint8
      img = np.asarray(list(pixels), output_type)
  
      if metadata["bitdepth"] == 8 and as_uint16:
          logger.warning(
              "You want to read image as uint16, but the original bit-depth is 8 bit."
              "All pixel values are simply increased by 256 times."
          )
          img *= 256
  
      # shape is (height, width * planes), planes = 1 (gray), 3 (rgb) or 4 (rgba)
  
      if not metadata["greyscale"]:
          # read image is rgb or rgba
          img = img.reshape((height, width, -1))
  
          if grayscale:
              img = PngBackend.rgb2gray(img).astype(output_type)
  
      img = PngBackend.convert_num_channles(img, num_channels)
  
      return img
  
file_path: nnabla/python/src/nnabla/utils/image_utils/backend_events/pypng_backend.py
imports: from __future__ import absolute_import, division
  import numpy
  import png
  from nnabla.logger import logger
  from .common import upscale_pixel_intensity, check_type_and_cast_if_necessary, _imread_before, _imread_after, _imsave_before
  from .image_utils_backend import ImageUtilsBackend
label_desc: Use image node_id 4 for calling the PngBackend obj's underlying member method code with example usage: obj.read_result_to_ndarray(pixels, width, height, metadata, grayscale, as_uint16, num_channels) and returns: img