import torch


def masked_min_pooling(data_tensor, mask, dim):
    """
    Performs masked min-pooling across the specified dimension of a Tensor.

    :param data_tensor: ND Tensor.
    :param mask: Tensor containing a binary mask that can be broad-casted to the shape of data_tensor.
    :param dim: Int that corresponds to the dimension.
    :return: (N-1)D Tensor containing the result of the min-pooling operation.
    """

    if dim < 0:
        dim = len(data_tensor.shape) + dim

    mask = mask.view(list(mask.shape) + [1] * (len(data_tensor.shape) - len(mask.shape)))
    data_tensor = data_tensor.masked_fill(mask == 0, 1e9)

    min_vals, min_ids = torch.min(data_tensor, dim=dim)

    return min_vals