class_docstr: ResNe(x)t_SlowFast backbone.
  Args:
      depth (int): Depth of resnet, from {50, 101, 152}.
      num_stages (int): Resnet stages, normally 4.
      strides (Sequence[int]): Strides of the first block of each stage.
      dilations (Sequence[int]): Dilation of each stage.
      out_indices (Sequence[int]): Output from which stages.
      style (str): `pytorch` or `caffe`. If set to "pytorch", the stride-two
          layer is the 3x3 conv layer, otherwise the stride-two layer is
          the first 1x1 conv layer.
      frozen_stages (int): Stages to be frozen (all param fixed). -1 means
          not freezing any parameters.
      bn_eval (bool): Whether to set BN layers to eval mode, namely, freeze
          running stats (mean and var).
      bn_frozen (bool): Whether to freeze weight and bias of BN layers.
      with_cp (bool): Use checkpoint or not. Using checkpoint will save some
          memory while slowing down the training speed.
class_docstr_tok: ["ResNe","(","x",")","t_SlowFast","backbone",".","Args",":","depth","(","int",")",":","Depth","of","resnet",",","from","{","50",",","101",",","152","}",".","num_stages","(","int",")",":","Resnet","stages",",","normally","4.","strides","(","Sequence","[","int","]",")",":","Strides","of","the","first","block","of","each","stage",".","dilations","(","Sequence","[","int","]",")",":","Dilation","of","each","stage",".","out_indices","(","Sequence","[","int","]",")",":","Output","from","which","stages",".","style","(","str",")",":","`","pytorch","`","or","`","caffe","`",".","If","set","to","``","pytorch","''",",","the","stride-two","layer","is","the","3x3","conv","layer",",","otherwise","the","stride-two","layer","is","the","first","1x1","conv","layer",".","frozen_stages","(","int",")",":","Stages","to","be","frozen","(","all","param","fixed",")",".","-1","means","not","freezing","any","parameters",".","bn_eval","(","bool",")",":","Whether","to","set","BN","layers","to","eval","mode",",","namely",",","freeze","running","stats","(","mean","and","var",")",".","bn_frozen","(","bool",")",":","Whether","to","freeze","weight","and","bias","of","BN","layers",".","with_cp","(","bool",")",":","Use","checkpoint","or","not",".","Using","checkpoint","will","save","some","memory","while","slowing","down","the","training","speed","."]
code: def __init__(
      self,
      depth,
      TPN_neck=None,
      num_classes=400,
      pretrained=None,
      pretrained_base=True,
      feat_ext=False,
      num_stages=4,
      spatial_strides=(1, 2, 2, 2),
      temporal_strides=(1, 1, 1, 1),
      dilations=(1, 1, 1, 1),
      out_indices=(2, 3),
      conv1_kernel_t=1,
      conv1_stride_t=1,
      pool1_kernel_t=1,
      pool1_stride_t=1,
      style="pytorch",
      frozen_stages=-1,
      inflate_freq=(0, 0, 1, 1),
      inflate_stride=(1, 1, 1, 1),
      inflate_style="3x1x1",
      nonlocal_stages=(-1,),
      nonlocal_freq=(0, 0, 0, 0),
      nonlocal_cfg=None,
      bn_eval=False,
      bn_frozen=False,
      partial_bn=False,
      with_cp=False,
      dropout_ratio=0.5,
      init_std=0.01,
  ):
      super(TPNet, self).__init__()
      if depth not in self.arch_settings:
          raise KeyError("invalid depth {} for resnet".format(depth))
      self.depth = depth
      self.pretrained = pretrained
      self.pretrained_base = pretrained_base
      self.num_classes = num_classes
      self.num_stages = num_stages
      assert 1 <= num_stages <= 4
      self.spatial_strides = spatial_strides
      self.temporal_strides = temporal_strides
      self.dilations = dilations
      assert (
          len(spatial_strides)
          == len(temporal_strides)
          == len(dilations)
          == num_stages
      )
      self.out_indices = out_indices
      assert max(out_indices) < num_stages
      self.style = style
      self.frozen_stages = frozen_stages
      self.inflate_freqs = (
          inflate_freq
          if not isinstance(inflate_freq, int)
          else (inflate_freq,) * num_stages
      )
      self.inflate_style = inflate_style
      self.nonlocal_stages = nonlocal_stages
      self.nonlocal_freqs = (
          nonlocal_freq
          if not isinstance(nonlocal_freq, int)
          else (nonlocal_freq,) * num_stages
      )
      self.nonlocal_cfg = nonlocal_cfg
      self.bn_eval = bn_eval
      self.bn_frozen = bn_frozen
      self.partial_bn = partial_bn
      self.with_cp = with_cp
      self.feat_ext = feat_ext
  
      self.dropout_ratio = dropout_ratio
      self.init_std = init_std
  
      self.block, stage_blocks = self.arch_settings[depth]
      self.stage_blocks = stage_blocks[:num_stages]
      self.inplanes = 64
  
      self.conv1 = nn.Conv3d(
          3,
          64,
          kernel_size=(conv1_kernel_t, 7, 7),
          stride=(conv1_stride_t, 2, 2),
          padding=((conv1_kernel_t - 1) // 2, 3, 3),
          bias=False,
      )
      self.bn1 = nn.BatchNorm3d(64)
      self.relu = nn.ReLU(inplace=True)
      self.maxpool = nn.MaxPool3d(
          kernel_size=(pool1_kernel_t, 3, 3),
          stride=(pool1_stride_t, 2, 2),
          padding=(pool1_kernel_t // 2, 1, 1),
      )
  
      self.res_layers = []
      for i, num_blocks in enumerate(self.stage_blocks):
          spatial_stride = spatial_strides[i]
          temporal_stride = temporal_strides[i]
          dilation = dilations[i]
          planes = 64 * 2**i
          res_layer = make_res_layer(
              self.block,
              self.inplanes,
              planes,
              num_blocks,
              spatial_stride=spatial_stride,
              temporal_stride=temporal_stride,
              dilation=dilation,
              style=self.style,
              inflate_freq=self.inflate_freqs[i],
              inflate_style=self.inflate_style,
              nonlocal_freq=self.nonlocal_freqs[i],
              nonlocal_cfg=self.nonlocal_cfg
              if i in self.nonlocal_stages
              else None,
              with_cp=with_cp,
          )
          self.inplanes = planes * self.block.expansion
          layer_name = "layer{}".format(i + 1)
          self.add_module(layer_name, res_layer)
          self.res_layers.append(layer_name)
  
      self.feat_dim = (
          self.block.expansion * 64 * 2 ** (len(self.stage_blocks) - 1)
      )
  
      self.TPN_neck = TPN_neck
  
      if self.dropout_ratio != 0:
          self.dropout = nn.Dropout(p=self.dropout_ratio)
      else:
          self.dropout = None
      self.avg_pool = nn.AdaptiveAvgPool3d(1)
      self.fc = nn.Linear(2048, self.num_classes)
      nn.init.normal_(self.fc.weight, 0, self.init_std)
      nn.init.constant_(self.fc.bias, 0)
      self.init_weights()
  
imports: import numpy
  import torch
  import torch.nn
  import torch.utils.checkpoint
  import torch.nn.functional
label_desc: Use image node_id 1 to create a new TPNet object from inherited base classes: nn with example: obj = TPNet(depth, TPN_neck, num_classes, pretrained, pretrained_base, feat_ext, num_stages, spatial_strides, temporal_strides, dilations, out_indices, conv1_kernel_t, conv1_stride_t, pool1_kernel_t, pool1_stride_t, style, frozen_stages, inflate_freq, inflate_stride, inflate_style, nonlocal_stages, nonlocal_freq, nonlocal_cfg, bn_eval, bn_frozen, partial_bn, with_cp, dropout_ratio, init_std)