class_docstr: A variant of MLP in which we introduce skip connections between
  successive layers in case the dimensions allow it
class_docstr_tok: ["A","variant","of","MLP","in","which","we","introduce","skip","connections","between","successive","layers","in","case","the","dimensions","allow","it"]
docstr: Args:
      batch (torch.Tensor): 2D torch tensor or 4D tensor of shape `N x C x 1 x 1`
  Returns:
      out (torch.Tensor): 2D output torch tensor
docstr_tok: ["Args",":","batch","(","torch.Tensor",")",":","2D","torch","tensor","or","4D","tensor","of","shape","`","N","x","C","x","1","x","1","`","Returns",":","out","(","torch.Tensor",")",":","2D","output","torch","tensor"]
code: def forward(self, batch: torch.Tensor):
      """
      Args:
          batch (torch.Tensor): 2D torch tensor or 4D tensor of shape `N x C x 1 x 1`
      Returns:
          out (torch.Tensor): 2D output torch tensor
      """
      if isinstance(batch, list):
          assert (
              len(batch) == 1
          ), "MLP input should be either a tensor (2D, 4D) or list containing 1 tensor."
          batch = batch[0]
  
      if batch.ndim > 2:
          assert all(
              d == 1 for d in batch.shape[2:]
          ), f"MLP expected 2D input tensor or 4D tensor of shape NxCx1x1. got: {batch.shape}"
          batch = batch.reshape((batch.size(0), batch.size(1)))
  
      x = batch
      for module in self.clf:
          delta = module(x)
          if x.shape == delta.shape:
              x = delta + x
          else:
              x = delta
      return x
  
file_path: vissl/vissl/models/heads/mlp_res.py
imports: from typing import List
  import torch
  import torch.nn
  from vissl.config import AttrDict
  from vissl.models.heads import register_model_head
label_desc: Use image node_id 4 for calling the MLPResidual obj's underlying member method code with example usage: obj.forward(batch) and returns: x