Could condense these two into `assert all(0 <= v < self.num_layers for v in value)`