code: def test_guided_attention_loss_value(device):
      from speechbrain.nnet.loss.guidedattn_loss import (
          GuidedAttentionLoss,
      )
  
      loss = GuidedAttentionLoss().to(device)
      input_lengths = torch.tensor([2, 3], device=device)
      target_lengths = torch.tensor([3, 4], device=device)
      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],
              ],
          ],
          device=device,
      )
      loss_value = loss(alignments, input_lengths, target_lengths)
      ref_loss_value = torch.tensor(0.1142)
      assert torch.isclose(
          loss_value, ref_loss_value, 0.0001, 0.0001
      ).item()
  
file_path: speechbrain/tests/unittests/test_losses.py
imports: import torch
  import pytest
label_desc: Use image node_id 9 for calling a global function with example usage: test_guided_attention_loss_value(device) without return types