class_docstr: A Convolutional feed-forward network, as proposed in VAN_ (Vision Attention Network, Guo et al.)
  
  .. _VAN: https://arxiv.org/pdf/2202.09741.pdf
class_docstr_tok: ["A","Convolutional","feed-forward","network",",","as","proposed","in","VAN_","(","Vision","Attention","Network",",","Guo","et","al",".",")","..","_VAN",":","https",":","\/\/arxiv.org\/pdf\/2202.09741.pdf"]
code: def forward(self, x):
      # The conv layers expect NCHW, we have NLC by default
      B, L, C = x.shape
      HW = int(math.sqrt(x.shape[-2]))
      assert (
          HW**2 == L
      ), "Conv2DFeedforward requires squared context lengths"
  
      x = x.reshape((B, HW, HW, C)).swapdims(1, -1)
  
      # The actual FW, including the 2d convolutions
      x = self.conv_mlp(x)
  
      # back to NLC
      x = x.transpose(1, -1)
      return x.flatten(1, 2)
  
file_path: xformers/xformers/components/feedforward/conv_mlp.py
imports: import math
  from dataclasses import dataclass
  from typing import Optional
  import torch.nn
  from xformers.components import Activation, build_activation
  from xformers.components.feedforward import Feedforward, FeedforwardConfig
  from .None import register_feedforward
label_desc: Use image node_id 3 for calling the Conv2DFeedforward obj's underlying member method code with example usage: obj.forward(x) and returns: x