class_docstr: An implementation of squeeze-and-excitation block.
  
  Arguments
  ---------
  in_channels : int
      The number of input channels.
  se_channels : int
      The number of output channels after squeeze.
  out_channels : int
      The number of output channels.
  
  Example
  -------
  >>> inp_tensor = torch.rand([8, 120, 64]).transpose(1, 2)
  >>> se_layer = SEBlock(64, 16, 64)
  >>> lengths = torch.rand((8,))
  >>> out_tensor = se_layer(inp_tensor, lengths).transpose(1, 2)
  >>> out_tensor.shape
  torch.Size([8, 120, 64])
class_docstr_tok: ["An","implementation","of","squeeze-and-excitation","block",".","Arguments","--","--","--","--","-","in_channels",":","int","The","number","of","input","channels",".","se_channels",":","int","The","number","of","output","channels","after","squeeze",".","out_channels",":","int","The","number","of","output","channels",".","Example","--","--","--","-",">",">",">","inp_tensor","=","torch.rand","(","[","8",",","120",",","64","]",")",".transpose","(","1",",","2",")",">",">",">","se_layer","=","SEBlock","(","64",",","16",",","64",")",">",">",">","lengths","=","torch.rand","(","(","8",",",")",")",">",">",">","out_tensor","=","se_layer","(","inp_tensor",",","lengths",")",".transpose","(","1",",","2",")",">",">",">","out_tensor.shape","torch.Size","(","[","8",",","120",",","64","]",")"]
docstr: Processes the input tensor x and returns an output tensor.
docstr_tok: ["Processes","the","input","tensor","x","and","returns","an","output","tensor","."]
code: def forward(self, x, lengths=None):
      """Processes the input tensor x and returns an output tensor."""
      L = x.shape[-1]
      if lengths is not None:
          mask = length_to_mask(lengths * L, max_len=L, device=x.device)
          mask = mask.unsqueeze(1)
          total = mask.sum(dim=2, keepdim=True)
          s = (x * mask).sum(dim=2, keepdim=True) / total
      else:
          s = x.mean(dim=2, keepdim=True)
  
      s = self.relu(self.conv1(s))
      s = self.sigmoid(self.conv2(s))
  
      return s * x
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from speechbrain.dataio.dataio import length_to_mask
  from speechbrain.nnet.CNN import Conv1d
  from speechbrain.nnet.normalization import BatchNorm1d
  from speechbrain.nnet.linear import Linear
label_desc: Use image node_id 2 for calling the SEBlock obj's underlying member method code with example usage: obj.forward(x, lengths) and returns: unknown