code: def test_labeled_accuracy_is_affected_by_incorrect_heads(
      self, device: str
  ):
      self._send_tensors_to_device(device)
  
      predictions = self.predictions
      # Change some stuff so our 4 of our predictions are wrong.
      predictions[0, 3:] = 3
      predictions[1, 0] = 7
      # This one is in the padded part, so it shouldn't affect anything.
      predictions[1, 5] = 7
      self.scorer(
          predictions,
          self.label_predictions,
          self.gold_indices,
          self.gold_labels,
          self.mask,
      )
  
      metrics = self.scorer.get_metric()
  
      # 4 heads are incorrect, so the unlabeled score should be
      # 6/10 = 0.6 LAS.
      assert metrics["UAS"] == 0.6
      # All the labels were correct, but some heads
      # were wrong, so the LAS should equal the UAS.
      assert metrics["LAS"] == 0.6
  
      # Neither batch element had a perfect labeled or unlabeled EM.
      assert metrics["LEM"] == 0.0
      assert metrics["UEM"] == 0.0
  
file_path: allennlp/tests/training/metrics/attachment_scores_test.py
imports: from typing import Any, Dict, List, Tuple, Union
  import torch
  from allennlp.common.testing import AllenNlpTestCase, multi_device, run_distributed_test, global_distributed_metric
  from allennlp.training.metrics import AttachmentScores
label_desc: Use image node_id 5 for calling the AttachmentScoresTest obj's underlying member method code with example usage: obj.test_labeled_accuracy_is_affected_by_incorrect_heads(device) without return types