That’s a rather uncommon use case. How would you define the last output layer, if the number of classes is unknown?
Are you planning to add an “unknown” class category which the model should use for all additional classes?