class_docstr: The base Attention mechanism, which is typically a sub-part of the multi-head attention
class_docstr_tok: ["The","base","Attention","mechanism",",","which","is","typically","a","sub-part","of","the","multi-head","attention"]
code: def from_config(cls: Type[Self], config: AttentionConfig) -> Self:
      # Generate the class inputs from the config
      fields = asdict(config)
  
      # Skip all Nones so that default values are used
      fields = {k: v for k, v in fields.items() if v is not None}
  
      return cls(**fields)
  
file_path: xformers/xformers/components/attention/base.py
imports: from abc import ABCMeta, abstractmethod
  from dataclasses import asdict, dataclass
  from typing import Optional, Type, TypeVar
  import torch
  import torch.nn
  from xformers.components.attention import AttentionMask
label_desc: Use image node_id 2 for calling the Attention obj's underlying member method code with example usage: obj.from_config(cls, config) and returns: cls