class_docstr: Re-implementation of the Squeeze-and-Excitation block based on:
  "Hu et al., Squeeze-and-Excitation Networks, https://arxiv.org/abs/1709.01507".
class_docstr_tok: ["Re-implementation","of","the","Squeeze-and-Excitation","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.
      r: the reduction ratio r in the paper. Defaults to 2.
      acti_type_1: activation type of the hidden squeeze layer. Defaults to ``("relu", {"inplace": True})``.
      acti_type_2: activation type of the output squeeze layer. Defaults to "sigmoid".
  
  Raises:
      ValueError: When ``r`` is nonpositive or larger than ``in_channels``.
  
  See also:
  
      :py:class:`monai.networks.layers.Act`
docstr_tok: ["Args",":","spatial_dims",":","number","of","spatial","dimensions",",","could","be","1",",","2",",","or","3.","in_channels",":","number","of","input","channels",".","r",":","the","reduction","ratio","r","in","the","paper",".","Defaults","to","2.","acti_type_1",":","activation","type","of","the","hidden","squeeze","layer",".","Defaults","to","``","(","``","relu","''",",","{","``","inplace","''",":","True","}",")","``",".","acti_type_2",":","activation","type","of","the","output","squeeze","layer",".","Defaults","to","``","sigmoid","''",".","Raises",":","ValueError",":","When","``","r","``","is","nonpositive","or","larger","than","``","in_channels","``",".","See","also",":",":","py",":","class",":","`","monai.networks.layers.Act","`"]
code: def __init__(
      self,
      spatial_dims: int,
      in_channels: int,
      r: int = 2,
      acti_type_1: tuple[str, dict] | str = ("relu", {"inplace": True}),
      acti_type_2: tuple[str, dict] | str = "sigmoid",
      add_residual: bool = False,
  ) -> None:
      """
      Args:
          spatial_dims: number of spatial dimensions, could be 1, 2, or 3.
          in_channels: number of input channels.
          r: the reduction ratio r in the paper. Defaults to 2.
          acti_type_1: activation type of the hidden squeeze layer. Defaults to ``("relu", {"inplace": True})``.
          acti_type_2: activation type of the output squeeze layer. Defaults to "sigmoid".
  
      Raises:
          ValueError: When ``r`` is nonpositive or larger than ``in_channels``.
  
      See also:
  
          :py:class:`monai.networks.layers.Act`
  
      """
      super().__init__()
  
      self.add_residual = add_residual
  
      pool_type = Pool[Pool.ADAPTIVEAVG, spatial_dims]
      self.avg_pool = pool_type(1)  # spatial size (1, 1, ...)
  
      channels = int(in_channels // r)
      if channels <= 0:
          raise ValueError(
              f"r must be positive and smaller than in_channels, got r={r} in_channels={in_channels}."
          )
  
      act_1, act_1_args = split_args(acti_type_1)
      act_2, act_2_args = split_args(acti_type_2)
      self.fc = nn.Sequential(
          nn.Linear(in_channels, channels, bias=True),
          Act[act_1](**act_1_args),
          nn.Linear(channels, in_channels, bias=True),
          Act[act_2](**act_2_args),
      )
  
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 ChannelSELayer object from inherited base classes: nn with example: obj = ChannelSELayer(spatial_dims, in_channels, r, acti_type_1, acti_type_2, add_residual)