code: def to_png(x: Union[np.ndarray, JaxArray]) -> bytes:
      """Converts numpy array in (C,H,W) format into PNG format."""
      if isinstance(x, jn.ndarray):
          x = np.array(x)
      if x.dtype in (np.float64, np.float32, np.float16):
          x = np.transpose(normalize_to_uint8(x), (1, 2, 0))
      elif x.dtype != np.uint8:
          raise ValueError(
              "Unsupported array type, expecting float or uint8",
              x.dtype,
          )
      if x.shape[2] == 1:
          x = np.broadcast_to(x, x.shape[:2] + (3,))
      with io.BytesIO() as f:
          Image.fromarray(x).save(f, "png")
          return f.getvalue()
  
file_path: objax/objax/util/image.py
imports: import io
  from typing import Union, BinaryIO, IO
  import jax.numpy
  import numpy
  from PIL import Image
  from objax.typing import JaxArray
label_desc: Use image node_id 7 for calling a global function with example usage: to_png(x) and returns: f