def macs_bn(module, input, output):
    """MACs estimation for `torch.nn.modules.batchnorm._BatchNorm`"""
    norm_mac = 1
    scale_mac = 1 if module.affine else 0
    bn_mac = input.numel() * (norm_mac + scale_mac)
    tracking_mac = 0
    if module.track_running_stats and module.training:
        tracking_mac += module.num_features * (input.shape[0] * input.shape
            [2:].numel() - 1)
        active_elts = input.shape[0] * input.shape[2:].numel()
        tracking_mac += module.num_features * (2 * active_elts - 1)
        tracking_mac += 2 * module.num_features * 2
    return bn_mac + tracking_mac
