class_docstr: A loss implementation that forces attention matrices to be
  near-diagonal, imposing progressively larger penalties for paying
  attention to regions far away from the diagonal). It is useful
  for sequence-to-sequence models in which the sequence of outputs
  is expected to corrsespond closely to the sequence of inputs,
  such as TTS or G2P
  
  https://arxiv.org/abs/1710.08969
  
  The implementation is inspired by the R9Y9 DeepVoice3 model
  https://github.com/r9y9/deepvoice3_pytorch
  
  It should be roughly equivalent to it; however, it has been
  fully vectorized.
  
  Arguments
  ---------
  sigma:
      the guided attention weight
  
  Example
  -------
  NOTE: In a real scenario, the input_lengths and
  target_lengths would come from a data batch,
  whereas alignments would come from a model
  >>> import torch
  >>> from speechbrain.nnet.loss.guidedattn_loss import GuidedAttentionLoss
  >>> loss = GuidedAttentionLoss(sigma=0.2)
  >>> input_lengths = torch.tensor([2, 3])
  >>> target_lengths = torch.tensor([3, 4])
  >>> alignments = torch.tensor(
  ...     [
  ...         [
  ...             [0.8, 0.2, 0.0],
  ...             [0.4, 0.6, 0.0],
  ...             [0.2, 0.8, 0.0],
  ...             [0.0, 0.0, 0.0],
  ...         ],
  ...         [
  ...             [0.6, 0.2, 0.2],
  ...             [0.1, 0.7, 0.2],
  ...             [0.3, 0.4, 0.3],
  ...             [0.2, 0.3, 0.5],
  ...         ],
  ...     ]
  ... )
  >>> loss(alignments, input_lengths, target_lengths)
  tensor(0.1142)
code: def __init__(self, sigma=0.2):
      super().__init__()
      self.sigma = sigma
      self.weight_factor = 2 * (sigma**2)
  
imports: import torch
  from torch import nn
label_desc: Use image node_id 1 to create a new GuidedAttentionLoss object from inherited base classes: nn with example: obj = GuidedAttentionLoss(sigma)