class_docstr: Squeeze and excitation layer, as per https://arxiv.org/pdf/1709.01507.pdf
class_docstr_tok: ["Squeeze","and","excitation","layer",",","as","per","https",":","\/\/arxiv.org\/pdf\/1709.01507.pdf"]
code: def __init__(
      self,
      in_planes,
      reduction_ratio: Optional[int] = 16,
      reduced_planes: Optional[int] = None,
      activation: Optional[nn.Module] = None,
  ):
      super().__init__()
      self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
  
      # Either reduction_ratio is defined, or out_planes is defined,
      # neither both nor none of them
      assert bool(reduction_ratio) != bool(reduced_planes)
  
      if activation is None:
          activation = nn.ReLU()
  
      reduced_planes = (
          in_planes // reduction_ratio
          if reduced_planes is None
          else reduced_planes
      )
      self.excitation = nn.Sequential(
          nn.Conv2d(
              in_planes,
              reduced_planes,
              kernel_size=1,
              stride=1,
              bias=True,
          ),
          activation,
          nn.Conv2d(
              reduced_planes,
              in_planes,
              kernel_size=1,
              stride=1,
              bias=True,
          ),
          nn.Sigmoid(),
      )
  
imports: from typing import Optional
  import torch.nn
label_desc: Use image node_id 1 to create a new SqueezeAndExcitationLayer object from inherited base classes: nn with example: obj = SqueezeAndExcitationLayer(in_planes, reduction_ratio, reduced_planes, activation)