class_docstr: Base class for all models.
  
  [`ModelMixin`] takes care of storing the model configuration and provides methods for loading, downloading and
  saving models.
  
      - **config_name** ([`str`]) -- Filename to save a model to when calling [`~models.ModelMixin.save_pretrained`].
class_docstr_tok: ["Base","class","for","all","models",".","[","`","ModelMixin","`","]","takes","care","of","storing","the","model","configuration","and","provides","methods","for","loading",",","downloading","and","saving","models",".","-","*","*","config_name","*","*","(","[","`","str","`","]",")","--","Filename","to","save","a","model","to","when","calling","[","`","~models.ModelMixin.save_pretrained","`","]","."]
docstr: Enable memory efficient attention from [xFormers](https://facebookresearch.github.io/xformers/).
  
  When this option is enabled, you should observe lower GPU memory usage and a potential speed up during
  inference. Speed up during training is not guaranteed.
  
  <Tip warning={true}>
  
  ⚠️ When memory efficient attention and sliced attention are both enabled, memory efficient attention takes
  precedent.
  
  </Tip>
  
  Parameters:
      attention_op (`Callable`, *optional*):
          Override the default `None` operator for use as `op` argument to the
          [`memory_efficient_attention()`](https://facebookresearch.github.io/xformers/components/ops.html#xformers.ops.memory_efficient_attention)
          function of xFormers.
  
  Examples:
  
  ```py
  >>> import torch
  >>> from diffusers import UNet2DConditionModel
  >>> from xformers.ops import MemoryEfficientAttentionFlashAttentionOp
  
  >>> model = UNet2DConditionModel.from_pretrained(
  ...     "stabilityai/stable-diffusion-2-1", subfolder="unet", torch_dtype=torch.float16
  ... )
  >>> model = model.to("cuda")
  >>> model.enable_xformers_memory_efficient_attention(attention_op=MemoryEfficientAttentionFlashAttentionOp)
  ```
docstr_tok: ["Enable","memory","efficient","attention","from","[","xFormers","]","(","https",":","\/\/facebookresearch.github.io\/xformers\/",")",".","When","this","option","is","enabled",",","you","should","observe","lower","GPU","memory","usage","and","a","potential","speed","up","during","inference",".","Speed","up","during","training","is","not","guaranteed",".","<","Tip","warning=","{","true","}",">","\u26a0\ufe0f","When","memory","efficient","attention","and","sliced","attention","are","both","enabled",",","memory","efficient","attention","takes","precedent",".","<","\/Tip",">","Parameters",":","attention_op","(","`","Callable","`",",","*","optional","*",")",":","Override","the","default","`","None","`","operator","for","use","as","`","op","`","argument","to","the","[","`","memory_efficient_attention","(",")","`","]","(","https",":","\/\/facebookresearch.github.io\/xformers\/components\/ops.html","#","xformers.ops.memory_efficient_attention",")","function","of","xFormers",".","Examples",":","``","`","py",">",">",">","import","torch",">",">",">","from","diffusers","import","UNet2DConditionModel",">",">",">","from","xformers.ops","import","MemoryEfficientAttentionFlashAttentionOp",">",">",">","model","=","UNet2DConditionModel.from_pretrained","(","...","``","stabilityai\/stable-diffusion-2-1","''",",","subfolder=","''","unet","''",",","torch_dtype=torch.float16","...",")",">",">",">","model","=","model.to","(","``","cuda","''",")",">",">",">","model.enable_xformers_memory_efficient_attention","(","attention_op=MemoryEfficientAttentionFlashAttentionOp",")","``","`"]
code: def enable_xformers_memory_efficient_attention(
      self, attention_op: Optional[Callable] = None
  ) -> None:
      r"""
      Enable memory efficient attention from [xFormers](https://facebookresearch.github.io/xformers/).
  
      When this option is enabled, you should observe lower GPU memory usage and a potential speed up during
      inference. Speed up during training is not guaranteed.
  
      <Tip warning={true}>
  
      ⚠️ When memory efficient attention and sliced attention are both enabled, memory efficient attention takes
      precedent.
  
      </Tip>
  
      Parameters:
          attention_op (`Callable`, *optional*):
              Override the default `None` operator for use as `op` argument to the
              [`memory_efficient_attention()`](https://facebookresearch.github.io/xformers/components/ops.html#xformers.ops.memory_efficient_attention)
              function of xFormers.
  
      Examples:
  
      ```py
      >>> import torch
      >>> from diffusers import UNet2DConditionModel
      >>> from xformers.ops import MemoryEfficientAttentionFlashAttentionOp
  
      >>> model = UNet2DConditionModel.from_pretrained(
      ...     "stabilityai/stable-diffusion-2-1", subfolder="unet", torch_dtype=torch.float16
      ... )
      >>> model = model.to("cuda")
      >>> model.enable_xformers_memory_efficient_attention(attention_op=MemoryEfficientAttentionFlashAttentionOp)
      ```
      """
      self.set_use_memory_efficient_attention_xformers(
          True, attention_op
      )
  
imports: import inspect
  import itertools
  import os
  import re
  from collections import OrderedDict
  from functools import partial
  from typing import Any, Callable, List, Optional, Tuple, Union
  import safetensors
  import torch
  from huggingface_hub import create_repo
  from huggingface_hub.utils import validate_hf_hub_args
  from torch import Tensor, nn
  from ..None import __version__
  from ..utils import CONFIG_NAME, FLAX_WEIGHTS_NAME, SAFETENSORS_WEIGHTS_NAME, WEIGHTS_NAME, _add_variant, _get_model_file, deprecate, is_accelerate_available, is_torch_version, logging
  from ..utils.hub_utils import PushToHubMixin
label_desc: Use image node_id 7 for calling the ModelMixin obj's underlying member method code with example usage: obj.enable_xformers_memory_efficient_attention(attention_op) without return types