def _process_input(data, context):
    """ pre-process request input before it is sent to
        TensorFlow Serving REST API
    Args:
        data (obj): the request data, in format of dict or string
        context (Context): object containing request and configuration details
    Returns:
        (dict): a JSON-serializable dict that contains request body and headers
    """
    if context.request_content_type == 'application/json':
        data = data.read().decode("utf-8")
        return data if len(data) else ''
    raise ValueError('{{"error": "unsupported content type {}"}}'.format(
        context.request_content_type or "unknown"
    ))