Repository: stable-diffusion-webui
Issue: [Bug]: Textual-Inversion training fails with "Use cross attention optimizations while training" active
Labels: bug-report

### Is there an existing issue for this?

- [X] I have searched the existing issues and checked the recent builds/commits

### What happened?

When having the option "Use cross attention optimizations while training" enabled, the training fails at 0 steps. 
When disabling the Setting, the training starts normally.
See log belog

### Steps to reproduce the problem

1. Enable "Use cross attention optimizations while training" in Train settings
2. Train a new embedding, setting don't matter.


### What should have happened?

Training should start.

### Commit where the problem happens

50fb20ce

### What platforms do you use to access UI ?

Other/Cloud

### What browsers do you use to access the UI ?

Mozilla Firefox

### Command Line Arguments

_No response_

### Additional information, context and logs

```
2023-01-14T20:16:07.779856818Z Training at rate of 0.002 until step 3000
2023-01-14T20:16:07.779875489Z Preparing dataset...
2023-01-14T20:16:09.521869849Z 
  0%|          | 0/65 [00:00<?, ?it/s]
 35%|███▌      | 23/65 [00:00<00:00, 170.78it/s]
 63%|██████▎   | 41/65 [00:00<00:00, 35.63it/s] 
 78%|███████▊  | 51/65 [00:01<00:00, 43.97it/s]
 94%|█████████▍| 61/65 [00:01<00:00, 34.92it/s]
100%|██████████| 65/65 [00:01<00:00, 37.32it/s]
2023-01-14T20:16:09.754453689Z 
  0%|          | 0/3000 [00:00<?, ?it/s]Traceback (most recent call last):
2023-01-14T20:16:09.754471322Z   File "/workspace/stable-diffusion-webui/modules/textual_inversion/textual_inversion.py", line 454, in train_embedding
2023-01-14T20:16:09.754474475Z     scaler.scale(loss).backward()
2023-01-14T20:16:09.754476800Z   File "/workspace/venv/lib/python3.10/site-packages/torch/_tensor.py", line 396, in backward
2023-01-14T20:16:09.754479170Z     torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
2023-01-14T20:16:09.754481433Z   File "/workspace/venv/lib/python3.10/site-packages/torch/autograd/__init__.py", line 173, in backward
2023-01-14T20:16:09.754483686Z     Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
2023-01-14T20:16:09.754486033Z   File "/workspace/venv/lib/python3.10/site-packages/torch/autograd/function.py", line 253, in apply
2023-01-14T20:16:09.754488316Z     return user_fn(self, *args)
2023-01-14T20:16:09.754490375Z   File "/workspace/venv/lib/python3.10/site-packages/torch/utils/checkpoint.py", line 146, in backward
2023-01-14T20:16:09.754492598Z     torch.autograd.backward(outputs_with_grad, args_with_grad)
2023-01-14T20:16:09.754494724Z   File "/workspace/venv/lib/python3.10/site-packages/torch/autograd/__init__.py", line 173, in backward
2023-01-14T20:16:09.754496946Z     Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
2023-01-14T20:16:09.754499105Z   File "/workspace/venv/lib/python3.10/site-packages/torch/autograd/function.py", line 253, in apply
2023-01-14T20:16:09.754501352Z     return user_fn(self, *args)
2023-01-14T20:16:09.754503550Z   File "/workspace/venv/lib/python3.10/site-packages/torch/autograd/function.py", line 399, in wrapper
2023-01-14T20:16:09.754505815Z     outputs = fn(ctx, *args)
2023-01-14T20:16:09.754507889Z   File "/workspace/venv/lib/python3.10/site-packages/xformers/ops/fmha/__init__.py", line 111, in backward
```