code: def _causal_attention(
      k_prime: torch.Tensor, q_prime: torch.Tensor, v: torch.Tensor
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      # Algorithm 1 in the paper
      ref_v = torch.ones_like(v.unsqueeze(2))  # BATCH x SEQ x 1 x EMB
      Gps = k_prime.unsqueeze(3) * v.unsqueeze(2)
      Grenorm = k_prime.unsqueeze(3) * ref_v
  
      # Consolidate against the feature dimension
      att_raw = torch.einsum("bcfe,bcf->bce", Gps, q_prime)
      att_norm = torch.einsum("bcfe,bcf->bce", Grenorm, q_prime)
  
      # Cumulative sum over the sequence
      att_raw = att_raw.cumsum(2)
      att_norm = att_norm.cumsum(2)
  
      return att_raw, att_norm
  
file_path: xformers/xformers/components/attention/favor.py
imports: import logging
  import math
  from dataclasses import dataclass
  from typing import Optional, Tuple
  import torch
  import torch.nn
  from torch.cuda.amp import autocast
  from xformers.components.attention import Attention, AttentionConfig, register_attention
  from xformers.components.attention.feature_maps import FeatureMap, FeatureMapType, SMHyperbolic, SMOrf, SMReg
label_desc: Use image node_id 3 for calling the FavorAttention obj's underlying member method code with example usage: obj._causal_attention(k_prime, q_prime, v) and returns: att_raw,  att_norm