class_docstr: Implementation of the model H/ASP without batch normalization in speaker embedding. This model was proposed in: https://arxiv.org/abs/2009.14153
  Adapted from: https://github.com/clovaai/voxceleb_trainer
class_docstr_tok: ["Implementation","of","the","model","H\/ASP","without","batch","normalization","in","speaker","embedding",".","This","model","was","proposed","in",":","https",":","\/\/arxiv.org\/abs\/2009.14153","Adapted","from",":","https",":","\/\/github.com\/clovaai\/voxceleb_trainer"]
docstr: Forward pass of the model.
  
  Args:
      x (Tensor): Raw waveform signal or spectrogram frames. If input is a waveform, `torch_spec` must be `True`
          to compute the spectrogram on-the-fly.
      l2_norm (bool): Whether to L2-normalize the outputs.
  
  Shapes:
      - x: :math:`(N, 1, T_{in})` or :math:`(N, D_{spec}, T_{in})`
docstr_tok: ["Forward","pass","of","the","model",".","Args",":","x","(","Tensor",")",":","Raw","waveform","signal","or","spectrogram","frames",".","If","input","is","a","waveform",",","`","torch_spec","`","must","be","`","True","`","to","compute","the","spectrogram","on-the-fly",".","l2_norm","(","bool",")",":","Whether","to","L2-normalize","the","outputs",".","Shapes",":","-","x",":",":","math",":","`","(","N",",","1",",","T_","{","in","}",")","`","or",":","math",":","`","(","N",",","D_","{","spec","}",",","T_","{","in","}",")","`"]
code: def forward(self, x, l2_norm=False):
      """Forward pass of the model.
  
      Args:
          x (Tensor): Raw waveform signal or spectrogram frames. If input is a waveform, `torch_spec` must be `True`
              to compute the spectrogram on-the-fly.
          l2_norm (bool): Whether to L2-normalize the outputs.
  
      Shapes:
          - x: :math:`(N, 1, T_{in})` or :math:`(N, D_{spec}, T_{in})`
      """
      x.squeeze_(1)
      # if you torch spec compute it otherwise use the mel spec computed by the AP
      if self.use_torch_spec:
          x = self.torch_spec(x)
  
      if self.log_input:
          x = (x + 1e-6).log()
      x = self.instancenorm(x).unsqueeze(1)
  
      x = self.conv1(x)
      x = self.relu(x)
      x = self.bn1(x)
  
      x = self.layer1(x)
      x = self.layer2(x)
      x = self.layer3(x)
      x = self.layer4(x)
  
      x = x.reshape(x.size()[0], -1, x.size()[-1])
  
      w = self.attention(x)
  
      if self.encoder_type == "SAP":
          x = torch.sum(x * w, dim=2)
      elif self.encoder_type == "ASP":
          mu = torch.sum(x * w, dim=2)
          sg = torch.sqrt(
              (torch.sum((x**2) * w, dim=2) - mu**2).clamp(min=1e-5)
          )
          x = torch.cat((mu, sg), 1)
  
      x = x.view(x.size()[0], -1)
      x = self.fc(x)
  
      if l2_norm:
          x = torch.nn.functional.normalize(x, p=2, dim=1)
      return x
  
file_path: TTS/TTS/encoder/models/resnet.py
imports: import torch
  from torch import nn
  from TTS.encoder.models.base_encoder import BaseEncoder
label_desc: Use image node_id 5 for calling the ResNetSpeakerEncoder obj's underlying member method code with example usage: obj.forward(x, l2_norm) and returns: x