Optimally Deep Networks -- Adapting Model Depth to Datasets for Superior Efficiency