code: def test_sequence_accuracy_respects_mask(self, device: str):
      accuracy = SequenceAccuracy()
      gold = torch.tensor(
          [[1, 2, 3], [2, 4, 8], [0, 1, 1], [11, 13, 17]], device=device
      )
      predictions = torch.tensor(
          [
              [[1, 2, 3], [1, 2, -1]],
              [[2, 4, 8], [2, 5, 9]],
              [[-1, -1, -1], [0, 1, -1]],
              [[12, 13, 17], [11, 13, 18]],
          ],
          device=device,
      )
      mask = torch.tensor(
          [
              [False, True, True],
              [True, True, True],
              [True, True, False],
              [True, False, True],
          ],
          device=device,
      )
  
      accuracy(predictions, gold, mask)
      actual_accuracy = accuracy.get_metric()["accuracy"]
      assert_allclose(actual_accuracy, 3 / 4)
  
file_path: allennlp/tests/training/metrics/sequence_accuracy_test.py
imports: from typing import Any, Dict, List, Tuple, Union
  import torch
  from torch.testing import assert_allclose
  from allennlp.common.testing import AllenNlpTestCase, multi_device, global_distributed_metric, run_distributed_test
  from allennlp.training.metrics import SequenceAccuracy
label_desc: Use image node_id 2 for calling the SequenceAccuracyTest obj's underlying member method code with example usage: obj.test_sequence_accuracy_respects_mask(device) without return types