You could iterate the modules of the parent nn.Module, check for the mask attribute via hasattr and assign e.g. a new nn.Parameter to it as seen here:
class MyModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.mask = None
        

class MyModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.lin1 = nn.Linear(1, 1)
        self.mod1 = MyModule()
        self.lin2 = nn.Linear(1, 1)
        self.mod2 = MyModule()


model = MyModel()
print(dict(model.named_parameters()))
> {'lin1.weight': Parameter containing:
  tensor([[-0.3372]], requires_grad=True), 'lin1.bias': Parameter containing:
  tensor([0.7264], requires_grad=True), 'lin2.weight': Parameter containing:
  tensor([[0.0947]], requires_grad=True), 'lin2.bias': Parameter containing:
  tensor([0.2308], requires_grad=True)}

for name, module in model.named_modules():
    if hasattr(module, 'mask'):
        print('{} has mask attribute'.format(name))
        module.mask = nn.Parameter(torch.randn(1))
> mod1 has mask attribute
  mod2 has mask attribute

print(dict(model.named_parameters()))
> {'lin1.weight': Parameter containing:
  tensor([[-0.3372]], requires_grad=True), 'lin1.bias': Parameter containing:
  tensor([0.7264], requires_grad=True), 'mod1.mask': Parameter containing:
  tensor([-0.6128], requires_grad=True), 'lin2.weight': Parameter containing:
  tensor([[0.0947]], requires_grad=True), 'lin2.bias': Parameter containing:
  tensor([0.2308], requires_grad=True), 'mod2.mask': Parameter containing:
  tensor([-0.1601], requires_grad=True)}