There are internal checks as seen here 6, which replace the None values with the default ones.
Thanks for the information about the use case.
I’m unfortunately unsure, what the best way would be (probably reimplementing the batchnorm layer manually).
However, this hacky trick might also work for you:
bn = nn.BatchNorm2d(3, affine=False)
delattr(bn, 'weight')
delattr(bn, 'bias')
bn.register_buffer('weight', torch.ones(3) * 2)
bn.register_buffer('bias', torch.ones(3) * 2)

Note that this is completely untested code and might break in various ways, but you could try it and see, if that would be working.