import torch


def _rezise_targets(targets, height, width):
    """
    Resize the targets to the same size of logits (add height and width channels)
    """
    targets = torch.stack(targets)  # convert list of scalar tensors to single tensor
    targets = targets.view(
        targets.size(0), targets.size(1), 1, 1,  # add two dummy spatial dims
    )
    targets = targets.expand(
        targets.size(0), targets.size(1), height, width   # expand to spatial size of x
    )
    return targets