class_docstr: Reversible model builder. This builds the reversible transformer encoder
  and allows reversible training.
  
  Karttikeya Mangalam, Haoqi Fan, Yanghao Li, Chao-Yuan Wu, Bo Xiong,
  Christoph Feichtenhofer, Jitendra Malik
  "Reversible Vision Transformers"
  
  https://openaccess.thecvf.com/content/CVPR2022/papers/Mangalam_Reversible_Vision_Transformers_CVPR_2022_paper.pdf
class_docstr_tok: ["Reversible","model","builder",".","This","builds","the","reversible","transformer","encoder","and","allows","reversible","training",".","Karttikeya","Mangalam",",","Haoqi","Fan",",","Yanghao","Li",",","Chao-Yuan","Wu",",","Bo","Xiong",",","Christoph","Feichtenhofer",",","Jitendra","Malik","''","Reversible","Vision","Transformers","''","https",":","\/\/openaccess.thecvf.com\/content\/CVPR2022\/papers\/Mangalam_Reversible_Vision_Transformers_CVPR_2022_paper.pdf"]
code: def forward(self, x):
      # process the layers in a reversible stack and an irreversible stack.
      stack = []
      for l_i in range(len(self.layers)):
          if isinstance(self.layers[l_i], StageTransitionBlock):
              stack.append(("StageTransition", l_i))
          else:
              if len(stack) == 0 or stack[-1][0] == "StageTransition":
                  stack.append(("Reversible", []))
              stack[-1][1].append(l_i)
  
      for layer_seq in stack:
          if layer_seq[0] == "StageTransition":
              x = self.layers[layer_seq[1]](x)
  
          else:
              x = torch.cat([x, x], dim=-1)
  
              # no need for custom backprop in eval/model stat log
              if not self.training or self.no_custom_backward:
                  executing_fn = ReversibleMViT.vanilla_backward
              else:
                  executing_fn = RevBackProp.apply
  
              x = executing_fn(
                  x,
                  self.layers[layer_seq[1][0] : layer_seq[1][-1] + 1],
                  [],  # buffer activations
              )
  
      # Apply dropout
      x = nn.functional.dropout(
          x, p=self.dropout, training=self.training
      )
  
      return x
  
imports: import sys
  from functools import partial
  import torch
  from torch import nn
  from torch.autograd import Function
  from slowfast.models.attention import MultiScaleAttention, attention_pool
  from slowfast.models.common import Mlp, TwoStreamFusion, drop_path
  from slowfast.models.utils import round_width
label_desc: Use image node_id 3 for calling the ReversibleMViT obj's underlying member method code with example usage: obj.forward(x) and returns: x