class_docstr: Creates the Squeeze&Excitation + XResNet block.
class_docstr_tok: ["Creates","the","Squeeze","&","Excitation","+","XResNet","block","."]
code: def __init__(
      self,
      expansion: int,
      n_inputs: int,
      n_hidden: int,
      stride: int = 1,
      activation: str = ACT_RELU,
  ):
      super().__init__()
  
      n_inputs = n_inputs * expansion
      n_filters = n_hidden * expansion
  
      # convolution path
      if expansion == 1:
          layers = [
              make_conv_bn_act(
                  n_inputs,
                  n_hidden,
                  3,
                  stride=stride,
                  activation=activation,
              ),
              make_conv_bn_act(
                  n_hidden,
                  n_filters,
                  3,
                  zero_batch_norm=True,
                  use_activation=False,
              ),
          ]
      else:
          layers = [
              make_conv_bn_act(
                  n_inputs, n_hidden, 1, activation=activation
              ),
              make_conv_bn_act(
                  n_hidden,
                  n_hidden,
                  3,
                  stride=stride,
                  activation=activation,
              ),
              make_conv_bn_act(
                  n_hidden,
                  n_filters,
                  1,
                  zero_batch_norm=True,
                  use_activation=False,
              ),
          ]
  
      self.convs = nn.Sequential(*layers)
      self.activation = instantiate_activation_block(
          activation, inplace=True
      )
      self.se = ChannelSpatialGate2d(n_filters, reduction=4)
  
      # identity path
      if n_inputs == n_filters:
          self.id_conv = nn.Identity()
      else:
          self.id_conv = make_conv_bn_act(
              n_inputs, n_filters, kernel_size=1, use_activation=False
          )
      if stride == 1:
          self.pool = nn.Identity()
      else:
          self.pool = nn.AvgPool2d(2, ceil_mode=True)
  
imports: from collections import OrderedDict
  from typing import List, Union
  import torch
  from torch import nn
  from pytorch_toolbelt.modules import ACT_RELU, instantiate_activation_block, ChannelSpatialGate2d
  from pytorch_toolbelt.modules.encoders import EncoderModule, make_n_channel_input
label_desc: Use image node_id 1 to create a new SEXResNetBlock object from inherited base classes: nn with example: obj = SEXResNetBlock(expansion, n_inputs, n_hidden, stride, activation)