[docs]defregister_buffer(self, name:str, tensor: Optional[Tensor], persistent:bool=True)->None:r"""Adds a buffer to the module.
This is typically used to register a buffer that should not to be
considered a model parameter. For example, BatchNorm's ``running_mean``
isnot a parameter, but is part of the module's state. Buffers, by
default, are persistent and will be saved alongside parameters. This
behavior can be changed by setting :attr:`persistent` to ``False``. The
only difference between a persistent bufferand a non-persistent bufferis that the latter will not be a part of this module's
:attr:`state_dict`.
Buffers can be accessed as attributes using given names.
# Specify a path
PATH ="state_dict_model.pt"# Save
torch.save(net.state_dict(), PATH)# Load
model = Net()
model.load_state_dict(torch.load(PATH))
model.eval()