class_docstr: Adds a normalization before computing attention
  
  ..Note: If a list of inputs is passed, all of them get normalized
class_docstr_tok: ["Adds","a","normalization","before","computing","attention","..","Note",":","If","a","list","of","inputs","is","passed",",","all","of","them","get","normalized"]
code: def forward(self, inputs: List[torch.Tensor], **kwargs):
      assert len(inputs) > 0
  
      # Perf improvement: if the inputs are all the same, only norm once
      ids = [id(x) for x in inputs]
      if ids.count(ids[0]) == len(ids):
          # The same tensor is passed multiple times
          x_norm = self.norm(inputs[0])
          inputs_normed = [x_norm for _ in inputs]
      else:
          # The inputs differ, norm them all
          inputs_normed = [self.norm(x_) for x_ in inputs]
  
      if self.wrap_inputs:
          return self.sublayer(inputs=inputs_normed, **kwargs)
      else:
          return self.sublayer(*inputs_normed, **kwargs)
  
imports: from enum import Enum
  from typing import List, Optional, Tuple, Union
  import torch
  import torch.nn
  from xformers import _is_triton_available
  from collections import namedtuple
label_desc: Use image node_id 2 for calling the PreNorm obj's underlying member method code with example usage: obj.forward(inputs) and returns: self, self