I think example 1 and example 2 do the same thing. The setattr method 282 of nn.Module doesn’t call add_module directly but it does something similar.
In general, you won’t need to call add_module. One potential use case is the following:
class Net(nn.Module):
    def __init__(self):
	super(Net, self).__init__()
        modules = [...]  # some list of modules
        for module in modules:
            self.add_module(...)