def METHOD_NAME(self, mod: type[torch.nn.Module] | None = None) -> int:
    m = [m for _, m in self.net.named_modules()]
    if mod is not None:
        m = [_m for _m in m if isinstance(_m, mod)]
    return len(m)