class_docstr: "Regularized softmax kernel" estimator, SMREG+, as proposed in the Performers_ paper.
  
  _Performers: "Rethinking attention with performers." K. Choromanski et al. (2020).
  https://arxiv.org/pdf/2009.14794v1.pdf
class_docstr_tok: ["``","Regularized","softmax","kernel","''","estimator",",","SMREG+",",","as","proposed","in","the","Performers_","paper",".","_Performers",":","``","Rethinking","attention","with","performers",".","''","K.","Choromanski","et","al",".","(","2020",")",".","https",":","\/\/arxiv.org\/pdf\/2009.14794v1.pdf"]
code: def forward(self, x: torch.Tensor) -> torch.Tensor:
      # Softmax-dimension related scaling, shared for all kernels
      x_scaled = super().pre_scale(x)
  
      # Project onto the random feature map, concatenate both + and - results
      # This follows Lemma 1 in the original Performers Paper to best approximate a
      # softmax kernel (cosh representation + sample regularization)
      x_scaled = x_scaled @ self.features
      return torch.cat(
          [
              torch.exp(x_scaled + self.offset),
              torch.exp(-x_scaled + self.offset),
          ],
          dim=-1,
      )
  
imports: import math
  from enum import Enum, auto
  from typing import Optional
  import torch
  from torch.autograd.profiler import record_function
  from .base import FeatureMap
label_desc: Use image node_id 3 for calling the SMReg obj's underlying member method code with example usage: obj.forward(x) and returns: torch