class_docstr: Args:
code: def __init__(
      self,
      num_class,
      num_segments,
      modality,
      base_model="resnet101",
      new_length=None,
      consensus_type="avg",
      before_softmax=True,
      dropout=0.8,
      img_feature_dim=256,
      crop_num=1,
      partial_bn=True,
      pretrain="imagenet",
      is_shift=False,
      shift_div=8,
      shift_place="blockres",
      fc_lr5=False,
      temporal_pool=False,
      non_local=False,
  ):
      super().__init__()
      self.modality = modality
      self.num_segments = num_segments
      self.reshape = True
      self.before_softmax = before_softmax
      self.dropout = dropout
      self.crop_num = crop_num
      self.consensus_type = consensus_type
      self.img_feature_dim = img_feature_dim  # the dimension of the CNN feature to represent each frame
      self.pretrain = pretrain
  
      self.is_shift = is_shift
      self.shift_div = shift_div
      self.shift_place = shift_place
      self.base_model_name = base_model
      self.fc_lr5 = fc_lr5
      self.temporal_pool = temporal_pool
      self.non_local = non_local
  
      if not before_softmax and consensus_type != "avg":
          raise ValueError(
              "Only avg consensus can be used after Softmax"
          )
  
      if new_length is None:
          self.new_length = 1 if modality == "RGB" else 5
      else:
          self.new_length = new_length
  
      self._prepare_base_model(base_model)
  
      self._prepare_tsn(num_class)
  
      if self.modality == "Flow":
          self.base_model = self._construct_flow_model(self.base_model)
      elif self.modality == "RGBDiff":
          self.base_model = self._construct_diff_model(self.base_model)
  
      self.consensus = ConsensusModule(consensus_type)
  
      if not self.before_softmax:
          self.softmax = nn.Softmax()
  
      self._enable_pbn = partial_bn
      if partial_bn:
          self.partialbn(True)
  
imports: import torch
  from torch import nn
  from torch.nn.init import normal_, constant_
  import numpy
  import torchvision
  from towhee.models.utils.basic_ops import ConsensusModule
  from towhee.models.layers.non_local import make_non_local
  from towhee.models.tsm.mobilenet_v2 import mobilenet_v2, InvertedResidual
  from towhee.models.tsm.temporal_shift import TemporalShift, make_temporal_shift
  from towhee.models.tsm.config import _C
label_desc: Use image node_id 1 to create a new TSN object from inherited base classes: nn with example: obj = TSN(num_class, num_segments, modality, base_model, new_length, consensus_type, before_softmax, dropout, img_feature_dim, crop_num, partial_bn, pretrain, is_shift, shift_div, shift_place, fc_lr5, temporal_pool, non_local)