def METHOD_NAME(data: t.Any, headers: dict) -> str:
    """Deduct the response content type from the returned data, headers and operation spec.
    :param data: Response data
    :param headers: Headers returned by the handler.
    :return: Deducted content type
    :raises: NonConformingResponseHeaders if content type cannot be deducted.
    """
    content_type = headers.get("Content-Type")
    # TODO: don't default
    produces = list(set(operation.produces))
    if data is not None and not produces:
        produces = ["application/json"]
    if content_type:
        if content_type not in produces:
            raise NonConformingResponseHeaders(
                f"Returned content type ({content_type}) is not defined in operation spec "
                f"({operation.produces})."
            )
    else:
        if not produces:
            # Produces can be empty/ for empty responses
            pass
        elif len(produces) == 1:
            content_type = produces[0]
        elif isinstance(data, str) and "text/plain" in produces:
            content_type = "text/plain"
        elif (
            isinstance(data, bytes)
            or isinstance(data, (types.GeneratorType, collections.abc.Iterator))
        ) and "application/octet-stream" in produces:
            content_type = "application/octet-stream"
        else:
            raise NonConformingResponseHeaders(
                "Multiple response content types are defined in the operation spec, but the "
                "handler response did not specify which one to return."
            )
    return content_type