class_docstr: Holds an attention mask, along with a couple of helpers and attributes.
  
  .. note: this is an additive mask, meaning that coefficients which should be computed hold the '0.' value,
      and coefficients which should be skipped hold the '-inf' value. Any other value is possible if the purpose
      is to bias the attention computation for instance
  
  .. note: the attention mask dimensions are expected to be `[batch, to_sequence, from_sequence]`,
      `[to_sequence, from_sequence]`, or anything broadcastable in between
class_docstr_tok: ["Holds","an","attention","mask",",","along","with","a","couple","of","helpers","and","attributes",".","..","note",":","this","is","an","additive","mask",",","meaning","that","coefficients","which","should","be","computed","hold","the","'","0",".","'","value",",","and","coefficients","which","should","be","skipped","hold","the","'-inf","'","value",".","Any","other","value","is","possible","if","the","purpose","is","to","bias","the","attention","computation","for","instance","..","note",":","the","attention","mask","dimensions","are","expected","to","be","`","[","batch",",","to_sequence",",","from_sequence","]","`",",","`","[","to_sequence",",","from_sequence","]","`",",","or","anything","broadcastable","in","between"]
docstr: Create an AttentionMask given a boolean pattern.
  .. warning: we assume here that True implies that the value should be computed
docstr_tok: ["Create","an","AttentionMask","given","a","boolean","pattern",".","..","warning",":","we","assume","here","that","True","implies","that","the","value","should","be","computed"]
code: def from_bool(cls: Type[Self], x: torch.Tensor) -> Self:
      """
      Create an AttentionMask given a boolean pattern.
      .. warning: we assume here that True implies that the value should be computed
      """
      assert x.dtype == torch.bool
  
      additive_mask = torch.empty_like(
          x, dtype=torch.float, device=x.device
      )
      additive_mask.masked_fill_(x, 0.0)
      additive_mask.masked_fill_(~x, float("-inf"))
  
      return cls(additive_mask)
  
file_path: xformers/xformers/components/attention/attention_mask.py
imports: from typing import Optional, Type, TypeVar
  import torch
label_desc: Use image node_id 3 for calling the AttentionMask obj's underlying member method code with example usage: obj.from_bool(cls, x) and returns: cls