import torch


def BCEFlat(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
    """Same as F.binary_cross_entropy but flattens the input and target.

    Args:
        x : logits
        y: The corresponding targets.

    Returns:
        The computed Loss
    """
    x = torch.sigmoid(x)
    y = y.view(x.shape).type_as(x)
    return torch.nn.functional.binary_cross_entropy(x, y)