docstr: Read image by pypng module.
  
  Args:
      path (str or 'file object'): File path or object to read.
      grayscale (bool):
      size (tupple of int):
          (width, height).
          If None, output img shape depends on the files to read.
      channel_first (bool):
          This argument specifies the shape of img is whether (height, width, channel) or (channel, height, width).
          Default value is False, which means the img shape is (height, width, channel).
      interpolate (str):
          must be one of ["nearest", "box", "bilinear", "hamming", "bicubic", "lanczos"].
      as_uint16 (bool):
          If True, this function reads image as uint16.
      num_channels (int):
          channel size of output array.
          Default is -1 which preserves raw image shape.
  
  Returns:
      numpy.ndarray
docstr_tok: ["Read","image","by","pypng","module",".","Args",":","path","(","str","or","'file","object","'",")",":","File","path","or","object","to","read",".","grayscale","(","bool",")",":","size","(","tupple","of","int",")",":","(","width",",","height",")",".","If","None",",","output","img","shape","depends","on","the","files","to","read",".","channel_first","(","bool",")",":","This","argument","specifies","the","shape","of","img","is","whether","(","height",",","width",",","channel",")","or","(","channel",",","height",",","width",")",".","Default","value","is","False",",","which","means","the","img","shape","is","(","height",",","width",",","channel",")",".","interpolate","(","str",")",":","must","be","one","of","[","``","nearest","''",",","``","box","''",",","``","bilinear","''",",","``","hamming","''",",","``","bicubic","''",",","``","lanczos","''","]",".","as_uint16","(","bool",")",":","If","True",",","this","function","reads","image","as","uint16",".","num_channels","(","int",")",":","channel","size","of","output","array",".","Default","is","-1","which","preserves","raw","image","shape",".","Returns",":","numpy.ndarray"]
code: def imread(
      self,
      path,
      grayscale=False,
      size=None,
      interpolate="bilinear",
      channel_first=False,
      as_uint16=False,
      num_channels=-1,
  ):
      """
      Read image by pypng module.
  
      Args:
          path (str or 'file object'): File path or object to read.
          grayscale (bool):
          size (tupple of int):
              (width, height).
              If None, output img shape depends on the files to read.
          channel_first (bool):
              This argument specifies the shape of img is whether (height, width, channel) or (channel, height, width).
              Default value is False, which means the img shape is (height, width, channel).
          interpolate (str):
              must be one of ["nearest", "box", "bilinear", "hamming", "bicubic", "lanczos"].
          as_uint16 (bool):
              If True, this function reads image as uint16.
          num_channels (int):
              channel size of output array.
              Default is -1 which preserves raw image shape.
  
      Returns:
          numpy.ndarray
      """
  
      _imread_before(grayscale, num_channels)
  
      f = path if hasattr(path, "read") else open(path, "rb")
  
      r = png.Reader(file=f)
      width, height, pixels, metadata = r.asDirect()
  
      bit_depth = metadata.get("bitdepth")
  
      if bit_depth not in [8, 16]:
          logger.warning(
              "The bit-depth of the image you want to read is unsupported ({}bit)."
              "Currently, pypng backend`s imread supports only [8, 16] bit-depth."
              "the path for this image is {}".format(bit_depth, path)
          )
          return self.next_available(path).imread(
              path,
              grayscale=grayscale,
              size=size,
              interpolate=interpolate,
              channel_first=channel_first,
              as_uint16=as_uint16,
              num_channels=num_channels,
          )
  
      try:
          img = self.read_result_to_ndarray(
              pixels,
              width,
              height,
              metadata,
              grayscale,
              as_uint16,
              num_channels,
          )
      except:
          return self.next_available(path).imread(
              path,
              grayscale=grayscale,
              size=size,
              interpolate=interpolate,
              channel_first=channel_first,
              as_uint16=as_uint16,
              num_channels=num_channels,
          )
  
      return _imread_after(
          img, size, interpolate, channel_first, self.imresize
      )
  
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 6 for calling the PngBackend obj's underlying member method code with example usage: obj.imread(path, grayscale, size, interpolate, channel_first, as_uint16, num_channels) and returns: _imread_after, self, self