def _encode_image(image_array, fmt='PNG'):
    'encodes an (numpy) image array to string.\n\n  Args:\n    image_array: (numpy) image array\n    fmt: image format to use\n\n  Returns:\n    encoded image string\n  '
    pil_image = Image.fromarray(image_array)
    image_io = io.BytesIO()
    pil_image.save(image_io, format=fmt)
    return image_io.getvalue()
encodes an (numpy) image array to string.

Args:
  image_array: (numpy) image array
  fmt: image format to use

Returns:
  encoded image string
def _encode_image(image_array, fmt='PNG'):
    'encodes an (numpy) image array to string.\n\n  Args:\n    image_array: (numpy) image array\n    fmt: image format to use\n\n  Returns:\n    encoded image string\n  '
    pil_image = Image.fromarray(image_array)
    image_io = io.BytesIO()
    pil_image.save(image_io, format=fmt)
    return image_io.getvalue()