code: def test_top_k_categorical_accuracy_respects_mask(self):
      accuracy = CategoricalAccuracy(top_k=2)
      predictions = torch.Tensor(
          [
              [0.35, 0.25, 0.1, 0.1, 0.2],
              [0.1, 0.6, 0.1, 0.2, 0.0],
              [0.1, 0.2, 0.5, 0.2, 0.0],
          ]
      )
      targets = torch.Tensor([0, 3, 0])
      mask = torch.Tensor([0, 1, 1])
      accuracy(predictions, targets, mask)
      actual_accuracy = accuracy.get_metric()
      assert actual_accuracy == 0.50
  
imports: from __future__ import division
  from __future__ import with_statement
  from __future__ import absolute_import
  import torch
  import pytest
  import numpy
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.common.checks import ConfigurationError
  from allennlp.training.metrics import CategoricalAccuracy
label_desc: Use image node_id 4 for calling the CategoricalAccuracyTest obj's underlying member method code with example usage: obj.test_top_k_categorical_accuracy_respects_mask() without return types