class_docstr: Attention pooling layer for pooling speaker embeddings
  Reference: ECAPA-TDNN Embeddings for Speaker Diarization (https://arxiv.org/pdf/2104.01466.pdf)
  inputs:
      inp_filters: input feature channel length from encoder
      attention_channels: intermediate attention channel size
      kernel_size: kernel_size for TDNN and attention conv1d layers (default: 1)
      dilation: dilation size for TDNN and attention conv1d layers  (default: 1) 
class_docstr_tok: ["Attention","pooling","layer","for","pooling","speaker","embeddings","Reference",":","ECAPA-TDNN","Embeddings","for","Speaker","Diarization","(","https",":","\/\/arxiv.org\/pdf\/2104.01466.pdf",")","inputs",":","inp_filters",":","input","feature","channel","length","from","encoder","attention_channels",":","intermediate","attention","channel","size","kernel_size",":","kernel_size","for","TDNN","and","attention","conv1d","layers","(","default",":","1",")","dilation",":","dilation","size","for","TDNN","and","attention","conv1d","layers","(","default",":","1",")"]
code: def forward(self, x, length=None):
      max_len = x.size(2)
  
      if length is None:
          length = torch.ones(x.shape[0], device=x.device)
  
      mask, num_values = lens_to_mask(
          length, max_len=max_len, device=x.device
      )
  
      # encoder statistics
      mean, std = get_statistics_with_mask(x, mask / num_values)
      mean = mean.unsqueeze(2).repeat(1, 1, max_len)
      std = std.unsqueeze(2).repeat(1, 1, max_len)
      attn = torch.cat([x, mean, std], dim=1)
  
      # attention statistics
      attn = self.attention_layer(attn)  # attention pass
      attn = attn.masked_fill(mask == 0, -inf)
      alpha = F.softmax(attn, dim=2)  # attention values, α
      mu, sg = get_statistics_with_mask(x, alpha)  # µ and ∑
  
      # gather
      return torch.cat((mu, sg), dim=1).unsqueeze(2)
  
imports: from typing import List
  import torch
  from numpy import inf
  from torch import nn
  from torch.nn import functional
  from nemo.collections.asr.parts.submodules.jasper import get_same_padding, init_weights
label_desc: Use image node_id 2 for calling the AttentivePoolLayer obj's underlying member method code with example usage: obj.forward(x, length) and returns: torch