What are training dataset, validation dataset and testing dataset in k-fold cross validation? Question

*

*What are training dataset, validation dataset and testing dataset in K-fold cross validation?

*Which is used for model selection, validation dataset or testing dataset?

*Either validation dataset or testing dataset should be used for model selection. What is the one that isn't for model selection used for? (Why do we need both validation and testing?)

Background
I would like to use k-fold cross validation to find the "best" model, but am confused about the concept.
(1) Simple
The simplest way should be splitting my dataset into training dataset and testing dataset, fitting models with training dataset and then calculate scores using testing dataset. In the figure, I calculate one score per model and compare them.
I say testing dataset is used for model selection because scores are calculated based on the performance on testing dataset.

(2) k-fold cross validation
I originally thought k-fold cross validation would be repeating (1) k times. For example, if it's 4-fold cross validation, I calculate 4 scores per model and then find the mean value (mean score). At the end, I select the model with the highest mean score. In the figure, mean scores are 0.88 for Model 1, 0.85 for Model 2 and 0.93 for Model 3, so I conclude Model 3 is the best.
(2) is also the case where testing dataset is used for model selection.

(3) ??
Today I find separating a dataset into training, validation and testing. (Refer to the links below.) I am totally confused about this information and need help to understand this.
https://www.researchgate.net/figure/Schematic-for-10-fold-cross-validation-A-test-set-is-held-out-from-the-cross-validation_fig2_330765732
https://satishgunjal.com/kfold/


validation typically means for hyperparameter optimisation, test is for getting an estimate of performance on new data,
k-fold only splits your data into 2 datasets
you have to do nested k-fold to split into 3. ie you split into test + (train + validation) k_1 times. then for each of those k_1 splits you split the (train+validation ) k_2 times into train and validation
see eg  https://inria.github.io/scikit-learn-mooc/python_scripts/cross_validation_nested.html
(so your option 2 is fine fi you want to find the best model, but don't need to get an unbiased (not overoptimistic) estimate of the performance on new data
