class_docstr: Stage of 3D ResNet. It expects to have one or more tensors as input for
      single pathway (C2D, I3D, Slow), and multi-pathway (SlowFast) cases.
      More details can be found here:
  
      Christoph Feichtenhofer, Haoqi Fan, Jitendra Malik, and Kaiming He.
      "SlowFast networks for video recognition."
      https://arxiv.org/pdf/1812.03982.pdf
class_docstr_tok: ["Stage","of","3D","ResNet",".","It","expects","to","have","one","or","more","tensors","as","input","for","single","pathway","(","C2D",",","I3D",",","Slow",")",",","and","multi-pathway","(","SlowFast",")","cases",".","More","details","can","be","found","here",":","Christoph","Feichtenhofer",",","Haoqi","Fan",",","Jitendra","Malik",",","and","Kaiming","He",".","``","SlowFast","networks","for","video","recognition",".","''","https",":","\/\/arxiv.org\/pdf\/1812.03982.pdf"]
docstr: The `__init__` method of any subclass should also contain these arguments.
  ResStage builds p streams, where p can be greater or equal to one.
  Args:
      dim_in (list): list of p the channel dimensions of the input.
          Different channel dimensions control the input dimension of
          different pathways.
      dim_out (list): list of p the channel dimensions of the output.
          Different channel dimensions control the input dimension of
          different pathways.
      temp_kernel_sizes (list): list of the p temporal kernel sizes of the
          convolution in the bottleneck. Different temp_kernel_sizes
          control different pathway.
      stride (list): list of the p strides of the bottleneck. Different
          stride control different pathway.
      num_blocks (list): list of p numbers of blocks for each of the
          pathway.
      dim_inner (list): list of the p inner channel dimensions of the
          input. Different channel dimensions control the input dimension
          of different pathways.
      num_groups (list): list of number of p groups for the convolution.
          num_groups=1 is for standard ResNet like networks, and
          num_groups>1 is for ResNeXt like networks.
      num_block_temp_kernel (list): extent the temp_kernel_sizes to
          num_block_temp_kernel blocks, then fill temporal kernel size
          of 1 for the rest of the layers.
      nonlocal_inds (list): If the tuple is empty, no nonlocal layer will
          be added. If the tuple is not empty, add nonlocal layers after
          the index-th block.
      dilation (list): size of dilation for each pathway.
      nonlocal_group (list): list of number of p nonlocal groups. Each
          number controls how to fold temporal dimension to batch
          dimension before applying nonlocal transformation.
          https://github.com/facebookresearch/video-nonlocal-net.
      instantiation (string): different instantiation for nonlocal layer.
          Supports two different instantiation method:
              "dot_product": normalizing correlation matrix with L2.
              "softmax": normalizing correlation matrix with Softmax.
      trans_func_name (string): name of the the transformation function apply
          on the network.
      norm_module (nn.Module): nn.Module for the normalization layer. The
          default is nn.BatchNorm3d.
      drop_connect_rate (float): basic rate at which blocks are dropped,
          linearly increases from input to output blocks.
docstr_tok: ["The","`","__init__","`","method","of","any","subclass","should","also","contain","these","arguments",".","ResStage","builds","p","streams",",","where","p","can","be","greater","or","equal","to","one",".","Args",":","dim_in","(","list",")",":","list","of","p","the","channel","dimensions","of","the","input",".","Different","channel","dimensions","control","the","input","dimension","of","different","pathways",".","dim_out","(","list",")",":","list","of","p","the","channel","dimensions","of","the","output",".","Different","channel","dimensions","control","the","input","dimension","of","different","pathways",".","temp_kernel_sizes","(","list",")",":","list","of","the","p","temporal","kernel","sizes","of","the","convolution","in","the","bottleneck",".","Different","temp_kernel_sizes","control","different","pathway",".","stride","(","list",")",":","list","of","the","p","strides","of","the","bottleneck",".","Different","stride","control","different","pathway",".","num_blocks","(","list",")",":","list","of","p","numbers","of","blocks","for","each","of","the","pathway",".","dim_inner","(","list",")",":","list","of","the","p","inner","channel","dimensions","of","the","input",".","Different","channel","dimensions","control","the","input","dimension","of","different","pathways",".","num_groups","(","list",")",":","list","of","number","of","p","groups","for","the","convolution",".","num_groups=1","is","for","standard","ResNet","like","networks",",","and","num_groups",">","1","is","for","ResNeXt","like","networks",".","num_block_temp_kernel","(","list",")",":","extent","the","temp_kernel_sizes","to","num_block_temp_kernel","blocks",",","then","fill","temporal","kernel","size","of","1","for","the","rest","of","the","layers",".","nonlocal_inds","(","list",")",":","If","the","tuple","is","empty",",","no","nonlocal","layer","will","be","added",".","If","the","tuple","is","not","empty",",","add","nonlocal","layers","after","the","index-th","block",".","dilation","(","list",")",":","size","of","dilation","for","each","pathway",".","nonlocal_group","(","list",")",":","list","of","number","of","p","nonlocal","groups",".","Each","number","controls","how","to","fold","temporal","dimension","to","batch","dimension","before","applying","nonlocal","transformation",".","https",":","\/\/github.com\/facebookresearch\/video-nonlocal-net",".","instantiation","(","string",")",":","different","instantiation","for","nonlocal","layer",".","Supports","two","different","instantiation","method",":","``","dot_product","''",":","normalizing","correlation","matrix","with","L2",".","``","softmax","''",":","normalizing","correlation","matrix","with","Softmax",".","trans_func_name","(","string",")",":","name","of","the","the","transformation","function","apply","on","the","network",".","norm_module","(","nn.Module",")",":","nn.Module","for","the","normalization","layer",".","The","default","is","nn.BatchNorm3d",".","drop_connect_rate","(","float",")",":","basic","rate","at","which","blocks","are","dropped",",","linearly","increases","from","input","to","output","blocks","."]
code: def __init__(
      self,
      dim_in,
      dim_out,
      stride,
      temp_kernel_sizes,
      num_blocks,
      dim_inner,
      num_groups,
      num_block_temp_kernel,
      nonlocal_inds,
      nonlocal_group,
      nonlocal_pool,
      dilation,
      instantiation="softmax",
      trans_func_name="bottleneck_transform",
      stride_1x1=False,
      inplace_relu=True,
      norm_module=nn.BatchNorm3d,
      drop_connect_rate=0.0,
  ):
      """
      The `__init__` method of any subclass should also contain these arguments.
      ResStage builds p streams, where p can be greater or equal to one.
      Args:
          dim_in (list): list of p the channel dimensions of the input.
              Different channel dimensions control the input dimension of
              different pathways.
          dim_out (list): list of p the channel dimensions of the output.
              Different channel dimensions control the input dimension of
              different pathways.
          temp_kernel_sizes (list): list of the p temporal kernel sizes of the
              convolution in the bottleneck. Different temp_kernel_sizes
              control different pathway.
          stride (list): list of the p strides of the bottleneck. Different
              stride control different pathway.
          num_blocks (list): list of p numbers of blocks for each of the
              pathway.
          dim_inner (list): list of the p inner channel dimensions of the
              input. Different channel dimensions control the input dimension
              of different pathways.
          num_groups (list): list of number of p groups for the convolution.
              num_groups=1 is for standard ResNet like networks, and
              num_groups>1 is for ResNeXt like networks.
          num_block_temp_kernel (list): extent the temp_kernel_sizes to
              num_block_temp_kernel blocks, then fill temporal kernel size
              of 1 for the rest of the layers.
          nonlocal_inds (list): If the tuple is empty, no nonlocal layer will
              be added. If the tuple is not empty, add nonlocal layers after
              the index-th block.
          dilation (list): size of dilation for each pathway.
          nonlocal_group (list): list of number of p nonlocal groups. Each
              number controls how to fold temporal dimension to batch
              dimension before applying nonlocal transformation.
              https://github.com/facebookresearch/video-nonlocal-net.
          instantiation (string): different instantiation for nonlocal layer.
              Supports two different instantiation method:
                  "dot_product": normalizing correlation matrix with L2.
                  "softmax": normalizing correlation matrix with Softmax.
          trans_func_name (string): name of the the transformation function apply
              on the network.
          norm_module (nn.Module): nn.Module for the normalization layer. The
              default is nn.BatchNorm3d.
          drop_connect_rate (float): basic rate at which blocks are dropped,
              linearly increases from input to output blocks.
      """
      super(ResStage, self).__init__()
      assert all(
          (
              num_block_temp_kernel[i] <= num_blocks[i]
              for i in range(len(temp_kernel_sizes))
          )
      )
      self.num_blocks = num_blocks
      self.nonlocal_group = nonlocal_group
      self._drop_connect_rate = drop_connect_rate
      self.temp_kernel_sizes = [
          (temp_kernel_sizes[i] * num_blocks[i])[
              : num_block_temp_kernel[i]
          ]
          + [1] * (num_blocks[i] - num_block_temp_kernel[i])
          for i in range(len(temp_kernel_sizes))
      ]
      assert (
          len(
              {
                  len(dim_in),
                  len(dim_out),
                  len(temp_kernel_sizes),
                  len(stride),
                  len(num_blocks),
                  len(dim_inner),
                  len(num_groups),
                  len(num_block_temp_kernel),
                  len(nonlocal_inds),
                  len(nonlocal_group),
              }
          )
          == 1
      )
      self.num_pathways = len(self.num_blocks)
      self._construct(
          dim_in,
          dim_out,
          stride,
          dim_inner,
          num_groups,
          trans_func_name,
          stride_1x1,
          inplace_relu,
          nonlocal_inds,
          nonlocal_pool,
          instantiation,
          dilation,
          norm_module,
      )
  
imports: import torch
  import torch.nn
  from slowfast.models.common import drop_path
  from slowfast.models.nonlocal_helper import Nonlocal
  from slowfast.models.operators import SE, Swish
label_desc: Use image node_id 1 to create a new ResStage object from inherited base classes: nn with example: obj = ResStage(dim_in, dim_out, stride, temp_kernel_sizes, num_blocks, dim_inner, num_groups, num_block_temp_kernel, nonlocal_inds, nonlocal_group, nonlocal_pool, dilation, instantiation, trans_func_name, stride_1x1, inplace_relu, norm_module, drop_connect_rate)