code: def test_get_valid_tokens_mask(self, device: str):
      tensor = torch.tensor([[1, 2, 3, 0], [0, 1, 1, 0]], device=device)
      result = get_valid_tokens_mask(
          tensor, self.metric._exclude_indices
      ).long()
      check = torch.tensor([[1, 1, 1, 0], [0, 1, 1, 0]], device=device)
      assert_allclose(result, check)
  
file_path: allennlp/tests/training/metrics/bleu_test.py
imports: from typing import Any, Dict, List, Tuple, Union
  import math
  from collections import Counter
  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 BLEU
  from allennlp.training.util import ngrams, get_valid_tokens_mask
label_desc: Use image node_id 2 for calling the BleuTest obj's underlying member method code with example usage: obj.test_get_valid_tokens_mask(device) without return types