import torch


def _compute_tensor_center(size, device, dtype):
    """
        Computes the center of tensor plane for (H, W), (C, H, W) and (B, C, H, W).
    """

    height, width = size

    center_x = float(width - 1) / 2
    center_y = float(height - 1) / 2

    center = torch.tensor([center_x, center_y], device=device, dtype=dtype)

    return center