class_docstr: Residual module enhanced with Squeeze-and-Excitation::
  
      ----+- conv1 --  conv2 -- conv3 -- SE -o---
          |                                  |
          +---(channel project if needed)----+
  
  Re-implementation of the SE-Resnet block based on:
  "Hu et al., Squeeze-and-Excitation Networks, https://arxiv.org/abs/1709.01507".
class_docstr_tok: ["Residual","module","enhanced","with","Squeeze-and-Excitation",":",":","--","--","+-","conv1","--","conv2","--","conv3","--","SE","-o","--","-","|","|","+","--","-","(","channel","project","if","needed",")","--","--","+","Re-implementation","of","the","SE-Resnet","block","based","on",":","''","Hu","et","al.",",","Squeeze-and-Excitation","Networks",",","https",":","\/\/arxiv.org\/abs\/1709.01507","''","."]
docstr: Args:
      spatial_dims: number of spatial dimensions, could be 1, 2, or 3.
      in_channels: number of input channels.
      n_chns_1: number of output channels in the 1st convolution.
      n_chns_2: number of output channels in the 2nd convolution.
      n_chns_3: number of output channels in the 3rd convolution.
      conv_param_1: additional parameters to the 1st convolution.
          Defaults to ``{"kernel_size": 1, "norm": Norm.BATCH, "act": ("relu", {"inplace": True})}``
      conv_param_2: additional parameters to the 2nd convolution.
          Defaults to ``{"kernel_size": 3, "norm": Norm.BATCH, "act": ("relu", {"inplace": True})}``
      conv_param_3: additional parameters to the 3rd convolution.
          Defaults to ``{"kernel_size": 1, "norm": Norm.BATCH, "act": None}``
      project: in the case of residual chns and output chns doesn't match, a project
          (Conv) layer/block is used to adjust the number of chns. In SENET, it is
          consisted with a Conv layer as well as a Norm layer.
          Defaults to None (chns are matchable) or a Conv layer with kernel size 1.
      r: the reduction ratio r in the paper. Defaults to 2.
      acti_type_1: activation type of the hidden squeeze layer. Defaults to "relu".
      acti_type_2: activation type of the output squeeze layer. Defaults to "sigmoid".
      acti_type_final: activation type of the end of the block. Defaults to "relu".
  
  See also:
  
      :py:class:`monai.networks.blocks.ChannelSELayer`
docstr_tok: ["Args",":","spatial_dims",":","number","of","spatial","dimensions",",","could","be","1",",","2",",","or","3.","in_channels",":","number","of","input","channels",".","n_chns_1",":","number","of","output","channels","in","the","1st","convolution",".","n_chns_2",":","number","of","output","channels","in","the","2nd","convolution",".","n_chns_3",":","number","of","output","channels","in","the","3rd","convolution",".","conv_param_1",":","additional","parameters","to","the","1st","convolution",".","Defaults","to","``","{","``","kernel_size","''",":","1",",","``","norm","''",":","Norm.BATCH",",","``","act","''",":","(","``","relu","''",",","{","``","inplace","''",":","True","}",")","}","``","conv_param_2",":","additional","parameters","to","the","2nd","convolution",".","Defaults","to","``","{","``","kernel_size","''",":","3",",","``","norm","''",":","Norm.BATCH",",","``","act","''",":","(","``","relu","''",",","{","``","inplace","''",":","True","}",")","}","``","conv_param_3",":","additional","parameters","to","the","3rd","convolution",".","Defaults","to","``","{","``","kernel_size","''",":","1",",","``","norm","''",":","Norm.BATCH",",","``","act","''",":","None","}","``","project",":","in","the","case","of","residual","chns","and","output","chns","does","n't","match",",","a","project","(","Conv",")","layer\/block","is","used","to","adjust","the","number","of","chns",".","In","SENET",",","it","is","consisted","with","a","Conv","layer","as","well","as","a","Norm","layer",".","Defaults","to","None","(","chns","are","matchable",")","or","a","Conv","layer","with","kernel","size","1.","r",":","the","reduction","ratio","r","in","the","paper",".","Defaults","to","2.","acti_type_1",":","activation","type","of","the","hidden","squeeze","layer",".","Defaults","to","``","relu","''",".","acti_type_2",":","activation","type","of","the","output","squeeze","layer",".","Defaults","to","``","sigmoid","''",".","acti_type_final",":","activation","type","of","the","end","of","the","block",".","Defaults","to","``","relu","''",".","See","also",":",":","py",":","class",":","`","monai.networks.blocks.ChannelSELayer","`"]
code: def __init__(
      self,
      spatial_dims: int,
      in_channels: int,
      n_chns_1: int,
      n_chns_2: int,
      n_chns_3: int,
      conv_param_1: dict | None = None,
      conv_param_2: dict | None = None,
      conv_param_3: dict | None = None,
      project: Convolution | None = None,
      r: int = 2,
      acti_type_1: tuple[str, dict] | str = ("relu", {"inplace": True}),
      acti_type_2: tuple[str, dict] | str = "sigmoid",
      acti_type_final: tuple[str, dict]
      | str
      | None = ("relu", {"inplace": True}),
  ):
      """
      Args:
          spatial_dims: number of spatial dimensions, could be 1, 2, or 3.
          in_channels: number of input channels.
          n_chns_1: number of output channels in the 1st convolution.
          n_chns_2: number of output channels in the 2nd convolution.
          n_chns_3: number of output channels in the 3rd convolution.
          conv_param_1: additional parameters to the 1st convolution.
              Defaults to ``{"kernel_size": 1, "norm": Norm.BATCH, "act": ("relu", {"inplace": True})}``
          conv_param_2: additional parameters to the 2nd convolution.
              Defaults to ``{"kernel_size": 3, "norm": Norm.BATCH, "act": ("relu", {"inplace": True})}``
          conv_param_3: additional parameters to the 3rd convolution.
              Defaults to ``{"kernel_size": 1, "norm": Norm.BATCH, "act": None}``
          project: in the case of residual chns and output chns doesn't match, a project
              (Conv) layer/block is used to adjust the number of chns. In SENET, it is
              consisted with a Conv layer as well as a Norm layer.
              Defaults to None (chns are matchable) or a Conv layer with kernel size 1.
          r: the reduction ratio r in the paper. Defaults to 2.
          acti_type_1: activation type of the hidden squeeze layer. Defaults to "relu".
          acti_type_2: activation type of the output squeeze layer. Defaults to "sigmoid".
          acti_type_final: activation type of the end of the block. Defaults to "relu".
  
      See also:
  
          :py:class:`monai.networks.blocks.ChannelSELayer`
  
      """
      super().__init__()
  
      if not conv_param_1:
          conv_param_1 = {
              "kernel_size": 1,
              "norm": Norm.BATCH,
              "act": ("relu", {"inplace": True}),
          }
      self.conv1 = Convolution(
          spatial_dims=spatial_dims,
          in_channels=in_channels,
          out_channels=n_chns_1,
          **conv_param_1,
      )
  
      if not conv_param_2:
          conv_param_2 = {
              "kernel_size": 3,
              "norm": Norm.BATCH,
              "act": ("relu", {"inplace": True}),
          }
      self.conv2 = Convolution(
          spatial_dims=spatial_dims,
          in_channels=n_chns_1,
          out_channels=n_chns_2,
          **conv_param_2,
      )
  
      if not conv_param_3:
          conv_param_3 = {
              "kernel_size": 1,
              "norm": Norm.BATCH,
              "act": None,
          }
      self.conv3 = Convolution(
          spatial_dims=spatial_dims,
          in_channels=n_chns_2,
          out_channels=n_chns_3,
          **conv_param_3,
      )
  
      self.se_layer = ChannelSELayer(
          spatial_dims=spatial_dims,
          in_channels=n_chns_3,
          r=r,
          acti_type_1=acti_type_1,
          acti_type_2=acti_type_2,
      )
  
      if project is None and in_channels != n_chns_3:
          self.project = Conv[Conv.CONV, spatial_dims](
              in_channels, n_chns_3, kernel_size=1
          )
      elif project is None:
          self.project = nn.Identity()
      else:
          self.project = project
  
      if acti_type_final is not None:
          act_final, act_final_args = split_args(acti_type_final)
          self.act = Act[act_final](**act_final_args)
      else:
          self.act = nn.Identity()
  
imports: from __future__ import annotations
  import math
  import torch
  import torch.nn
  from monai.networks.blocks import Convolution
  from monai.networks.layers.factories import Act, Conv, Norm, Pool, split_args
label_desc: Use image node_id 1 to create a new SEBlock object from inherited base classes: nn with example: obj = SEBlock(spatial_dims, in_channels, n_chns_1, n_chns_2, n_chns_3, conv_param_1, conv_param_2, conv_param_3, project, r, acti_type_1, acti_type_2, acti_type_final)