code: def convert_num_channles(img, num_channels):
      src_channles = 0 if len(img.shape) == 2 else img.shape[-1]
      if src_channles == num_channels or num_channels == -1:
          return img
  
      if src_channles == 0:
          return np.broadcast_to(
              img[..., np.newaxis], img.shape + (num_channels,)
          )
  
      if num_channels == 3:
          return img[..., :3]
  
      if num_channels == 4:
          fill = 65535 if img.dtype == np.uint16 else 255
          alpha = (
              np.ones(img.shape[:-1] + (1,)).astype(img.dtype) * fill
          )
          return np.concatenate((img, alpha), axis=-1)
  
      raise ValueError("invalid number of channels")
  
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 3 for calling the PngBackend obj's underlying member method code with example usage: obj.convert_num_channles(img, num_channels) and returns: img, np, img, np