Hi, I think you can check this page to see what it is for:
github.com/pytorch/batchnorm.py 387
Just as its name implies, assuming you want to use torch.nn.BatchNorm2d (by default, with track_running_stats=True):

When you are at training, the num_batches_tracked (starting from zero) will plus 1 for each mini-batch.
If you didn’t specify momentum, which is used for calculating running mean and variance by exponential method, then it will use 1/num_batches_tracked as a factor to calculate them (i.e. cumulative method).

I guess it should be clear why we need this buffer.