Repository: facebookresearch/hydra

Issue:
[Bug] delete field when using optuna sweeper would throw error
# 🐛 Bug
## Description
<!-- A clear and concise description of what the bug is. -->
I was using optuna sweeper but I noticed that if i delete a field by `~field` it would throw an error.

## To reproduce
Let's [start with this](https://github.com/facebookresearch/hydra/tree/main/examples/advanced/defaults_list_interpolation). Let's modify `conf/db/sqlite.yaml` to be this
```yaml
name: sqlite

model:
  name: boring
```
then create a directory called `exp`, and create a file `exp/exp.yaml`
```yaml
# @package _global_

defaults:
  - override /hydra/sweeper: optuna
  - override /db: sqlite
```
Now run the command `python my_app.py -m +exp=exp ~db.model` it would have the error
> Could not delete from config. The value of 'db.model' is {'name': 'boring'} and not None.

However if I did `python my_app.py +exp=exp ~db.model` (not activating sweeper), then the code would run correctly, making the db to be sqlite (the default is mysql) and the `model.name` part deleted. 

## System information
- **Hydra Version** :  1.0.0.rc1
- **Python version** : 3.7.10
- **Operating system** : Ubuntu 18.04.2 LTS



Discussion:
hi @chris-tkinter 
you are using a example created with Hydra 1.1 running on Hydra 1.0. Could you first try running on the latest version of Hydra 1.1 and the optuna sweeper?
Hi @jieru-hu I tried this on the latest one and the problem still persists in 
```
hydra-colorlog              1.1.0.dev1
hydra-core                  1.1.1
hydra-optuna-sweeper        1.1.0.dev2
```
Thank you @chris-tkinter. This is indeed a bug.

This is due to the Optuna sweeper not casting the value correctly. Running the your example with a BasicSweeper it becomes obvious what is going wrong

### optuna sweeper
```
[2021-09-08 13:51:10,062][HYDRA] Launching 2 jobs locally
[2021-09-08 13:51:10,062][HYDRA]        #0 : +exp=exp ~db.model=None
Could not delete from config. The value of 'db.model' is {'name': 'boring'} and not None.

```

### BasicSweeper
```
[2021-09-08 13:52:47,036][HYDRA] Launching 1 jobs locally
[2021-09-08 13:52:47,036][HYDRA]        #0 : +exp=exp ~db.model=null
```

optuna sweeper parsed the overrides to be `~db.model=None` which validates that `db.model==None` before deleting the node. 


Resolving patch:
diff --git a/plugins/hydra_optuna_sweeper/hydra_plugins/hydra_optuna_sweeper/_impl.py b/plugins/hydra_optuna_sweeper/hydra_plugins/hydra_optuna_sweeper/_impl.py
--- a/plugins/hydra_optuna_sweeper/hydra_plugins/hydra_optuna_sweeper/_impl.py
+++ b/plugins/hydra_optuna_sweeper/hydra_plugins/hydra_optuna_sweeper/_impl.py
@@ -61,10 +61,10 @@ def create_optuna_distribution_from_config(
 
 
 def create_optuna_distribution_from_override(override: Override) -> Any:
-    value = override.value()
     if not override.is_sweep_override():
-        return value
+        return override.get_value_element_as_str()
 
+    value = override.value()
     choices: List[CategoricalChoiceType] = []
     if override.is_choice_sweep():
         assert isinstance(value, ChoiceSweep)


Test patch:
diff --git a/plugins/hydra_optuna_sweeper/tests/test_optuna_sweeper_plugin.py b/plugins/hydra_optuna_sweeper/tests/test_optuna_sweeper_plugin.py
--- a/plugins/hydra_optuna_sweeper/tests/test_optuna_sweeper_plugin.py
+++ b/plugins/hydra_optuna_sweeper/tests/test_optuna_sweeper_plugin.py
@@ -132,6 +132,7 @@ def test_optuna_example(with_commandline: bool, tmpdir: Path) -> None:
         f"hydra.sweeper.study_name={study_name}",
         "hydra/sweeper/sampler=tpe",
         "hydra.sweeper.sampler.seed=123",
+        "~z",
     ]
     if with_commandline:
         cmd += [