Repository: huggingface/diffusers

Issue:
dreambooth : ModelMixin.enable_xformers_memory_efficient_attention() takes 1 positional argument but 2 were given
### Describe the bug

I cant get xformers to run if I only run 
from diffusers.utils.import_utils import is_xformers_available

if is_xformers_available():

It says its available. 

The code is the train_dreambooth.py script

Thank you!

### Reproduction

vanilla train_dreambooth.py from the examples

### Logs

```shell
accelerate launch train_dreambooth.py --pretrained_model_name_or_path=$MODEL_NAME --save_steps=2000  --train_text_encoder --instance_data_dir=$INSTANCE_DIR --class_data_dir=$CLASS_DIR --output_dir=$OUTPUT_DIR --with_prior_preservation --prior_loss_weight=1.0 --instance_prompt="versipillis transform" --class_prompt="3D animal illustration" --resolution=768 --train_batch_size=1 --use_8bit_adam --gradient_checkpointing --learning_rate=7e-7 --lr_scheduler="constant" --lr_warmup_steps=0 --num_class_images=200 --max_train_steps=20000
You are using a model of type clip_text_model to instantiate a model of type . This is not supported for all configurations of models and can yield errors.
Could not enable memory efficient attention. Make sure xformers is installed correctly and a GPU is available: 'UNet2DConditionModel' object has no attribute 'enable_xformers'
Steps:   0%|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | 1/20000 [00:04<24:13:47,  4.36s/it, loss=0.354, lr=7e-7]Traceback (most recent call last):
  File "/dreambooth/train_dreambooth.py", line 730, in <module>
    main(args)
  File "/dreambooth/train_dreambooth.py", line 675, in main
    accelerator.backward(loss)
  File "/env/lib/python3.10/site-packages/accelerate/accelerator.py", line 1188, in backward
    self.scaler.scale(loss).backward(**kwargs)
  File "env/lib/python3.10/site-packages/torch/_tensor.py", line 487, in backward
    torch.autograd.backward(
  File "/env/lib/python3.10/site-packages/torch/autograd/__init__.py", line 197, in backward
    Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
  File "/env/lib/python3.10/site-packages/torch/autograd/function.py", line 267, in apply
    return user_fn(self, *args)
  File "env/lib/python3.10/site-packages/torch/utils/checkpoint.py", line 157, in backward
    torch.autograd.backward(outputs_with_grad, args_with_grad)
  File "env/lib/python3.10/site-packages/torch/autograd/__init__.py", line 197, in backward
    Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 3.16 GiB (GPU 0; 23.70 GiB total capacity; 17.03 GiB already allocated; 310.06 MiB free; 21.37 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
```


### System Info


- `diffusers` version: 0.10.2
- Platform: Linux-5.15.0-56-generic-x86_64-with-glibc2.31
- Python version: 3.10.6
- PyTorch version (GPU?): 1.13.0+cu116 (True)
- Huggingface_hub version: 0.11.1
- Transformers version: 4.26.0.dev0
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>


Discussion:

Resolving patch:
diff --git a/examples/dreambooth/train_dreambooth.py b/examples/dreambooth/train_dreambooth.py
--- a/examples/dreambooth/train_dreambooth.py
+++ b/examples/dreambooth/train_dreambooth.py
@@ -491,7 +491,7 @@ def main(args):
 
     if is_xformers_available():
         try:
-            unet.enable_xformers_memory_efficient_attention(True)
+            unet.enable_xformers_memory_efficient_attention()
         except Exception as e:
             logger.warning(
                 "Could not enable memory efficient attention. Make sure xformers is installed"
diff --git a/examples/text_to_image/train_text_to_image.py b/examples/text_to_image/train_text_to_image.py
--- a/examples/text_to_image/train_text_to_image.py
+++ b/examples/text_to_image/train_text_to_image.py
@@ -367,7 +367,7 @@ def main():
 
     if is_xformers_available():
         try:
-            unet.enable_xformers_memory_efficient_attention(True)
+            unet.enable_xformers_memory_efficient_attention()
         except Exception as e:
             logger.warning(
                 "Could not enable memory efficient attention. Make sure xformers is installed"
diff --git a/examples/textual_inversion/textual_inversion.py b/examples/textual_inversion/textual_inversion.py
--- a/examples/textual_inversion/textual_inversion.py
+++ b/examples/textual_inversion/textual_inversion.py
@@ -442,7 +442,7 @@ def main():
 
     if is_xformers_available():
         try:
-            unet.enable_xformers_memory_efficient_attention(True)
+            unet.enable_xformers_memory_efficient_attention()
         except Exception as e:
             logger.warning(
                 "Could not enable memory efficient attention. Make sure xformers is installed"


Test patch: