def masked_minimum(F, data, mask, dim=1):
    """Computes the axis wise minimum over chosen elements.
    Args:
      data: 2-D float `Tensor` of size [n, m].
      mask: 2-D Boolean `Tensor` of size [n, m].
      dim: The dimension over which to compute the minimum.
    Returns:
      masked_minimums: N-D `Tensor`.
        The minimized dimension is of size 1 after the operation.
    """
    axis_maximums = F.max(data, dim, keepdims=True)
    masked_minimums = F.min((F.broadcast_sub(data, axis_maximums)) * mask, dim, keepdims=True) + axis_maximums
    return masked_minimums