### Problem: Hyperparameter Search
You are given a machine learning model and a set of hyperparameters to search over. Write a function that performs a grid search over the hyperparameters to find the best combination that results in the highest accuracy.
#### Example:
Suppose we have a machine learning model model and a set of hyperparameters hyperparameters to search over. We can use the function to perform a grid search as follows:
model = ... # load the machine learning model
hyperparameters = {'learning_rate': [0.1, 0.5, 1.0], 'batch_size': [32, 64, 128]}
best_hyperparameters, best_accuracy = grid_search(model, hyperparameters)
Test Cases
Test Case 1
Input:
{"learning_rate": [0.1, 0.5, 1.0], "batch_size": [32, 64, 128]}Expected:
[{'learning_rate': 0.1, 'batch_size': 32}, {'learning_rate': 0.5, 'batch_size': 64}, {'learning_rate': 1.0, 'batch_size': 128}]Test Case 2
Input:
{"learning_rate": [0.1, 0.5, 1.0], "batch_size": [32, 64, 128]}Expected:
[{'learning_rate': 0.1, 'batch_size': 32}, {'learning_rate': 0.5, 'batch_size': 64}, {'learning_rate': 1.0, 'batch_size': 128}]+ 3 hidden test cases