It’s basically the number of input and output activations.
For a linear layer layer it would be just fan_in = in_features and fan_out = out_features:
print(torch.nn.init._calculate_fan_in_and_fan_out(nn.Linear(10, 2).weight))

In the case of nn.Conv2d it’s a bit more complicated, as you need to calculate receptive field using the kernel size, the in_channels, and number of filters:
print(torch.nn.init._calculate_fan_in_and_fan_out(nn.Conv2d(3, 1, 3, 1, 1).weight))

You can find the formula here 41.