def METHOD_NAME(self, arr: np.ndarray) -> bytes:
    """
    Converts a numpy array to bytes
    Args:
        arr (np.array): numpy array representing the image
    Returns:
        png encoded bytes
    """
    if len(arr.shape) != 3:
        raise ValueError(
            "unsupported image format. Must be 3D ([H,W,C])."
            f"Use {self.__class__.__name__}.from_2D_arr to construct from 2D"
        )
    if arr.dtype != np.uint8:
        raise TypeError(f"image data type must be uint8. Found {arr.dtype}")
    im_bytes = BytesIO()
    Image.fromarray(arr).save(im_bytes, format="PNG")
    return im_bytes.getvalue()