code: def _encode_image(self, np_image):
      
      if np_image.dtype != np.uint8:
        raise ValueError('Image should be uint8. Detected: %s.' % np_image.dtype)
      utils.assert_shape_match(np_image.shape, self._shape)
      return self._runner.run(ENCODE_FN[self._encoding_format], np_image)
docs: Returns np_image encoded as jpeg or png.