class_docstr: Parent class for 2-layer (BasicLayer) and 3-layer (BottleneckLayer)
  bottleneck layer class
class_docstr_tok: ["Parent","class","for","2-layer","(","BasicLayer",")","and","3-layer","(","BottleneckLayer",")","bottleneck","layer","class"]
code: def __init__(
      self,
      convolutional_block,
      in_planes,
      out_planes,
      stride=1,
      mid_planes_and_cardinality=None,
      reduction=4,
      final_bn_relu=True,
      use_se=False,
      se_reduction_ratio=16,
  ):
      # assertions on inputs:
      assert is_pos_int(in_planes) and is_pos_int(out_planes)
      assert (
          is_pos_int(stride) or is_pos_int_tuple(stride)
      ) and is_pos_int(reduction)
  
      # set object fields:
      super(GenericLayer, self).__init__()
      self.convolutional_block = convolutional_block
      self.final_bn_relu = final_bn_relu
  
      # final batchnorm and relu layer:
      if final_bn_relu:
          self.bn = nn.BatchNorm2d(out_planes)
          self.relu = nn.ReLU(inplace=INPLACE)
  
      # define down-sampling layer (if direct residual impossible):
      self.downsample = None
      if (stride != 1 and stride != (1, 1)) or in_planes != out_planes:
          self.downsample = nn.Sequential(
              conv1x1(in_planes, out_planes, stride=stride),
              nn.BatchNorm2d(out_planes),
          )
  
      self.se = (
          SqueezeAndExcitationLayer(
              out_planes, reduction_ratio=se_reduction_ratio
          )
          if use_se
          else None
      )
  
imports: import copy
  import math
  import re
  import warnings
  from collections import OrderedDict
  from typing import Any, Dict, Optional, Sequence
  import torch.nn
  from classy_vision.generic.util import is_pos_int, is_pos_int_tuple
  from .None import register_model
  from .classy_model import ClassyModel
  from .squeeze_and_excitation_layer import SqueezeAndExcitationLayer
label_desc: Use image node_id 1 to create a new GenericLayer object from inherited base classes: nn with example: obj = GenericLayer(convolutional_block, in_planes, out_planes, stride, mid_planes_and_cardinality, reduction, final_bn_relu, use_se, se_reduction_ratio)