import torch


def compute_class_weight(n_samples, n_classes, class_bincount):
    """
    Estimate class weights for unbalanced datasets.
    Class weights are calculated by: n_samples / (n_classes * class_sample_count)
    :param n_samples:
    :param n_classes:
    :param class_bincount:
    :return:
    """
    return torch.FloatTensor(n_samples / (n_classes * class_bincount))