import torch


def reduce(tensor: torch.Tensor, reduction: str) -> torch.Tensor:
    """Reduces the given tensor using a specific criterion.

    Args:
        tensor (torch.Tensor): input tensor
        reduction (str): string with fixed values [elementwise_mean, none, sum]

    Raises:
        ValueError: when the reduction is not supported

    Returns:
        torch.Tensor: reduced tensor, or the tensor itself
    """
    if reduction in ("elementwise_mean", "mean"):
        return torch.mean(tensor)
    if reduction == 'sum':
        return torch.sum(tensor)
    if reduction is None or reduction == 'none':
        return tensor
    raise ValueError('Reduction parameter unknown.')