code: def test_compute():
      acc = TopKCategoricalAccuracy(2)
  
      y_pred = torch.FloatTensor(
          [[0.2, 0.4, 0.6, 0.8], [0.8, 0.6, 0.4, 0.2]]
      )
      y = torch.ones(2).long()
      acc.update((y_pred, y))
      assert isinstance(acc.compute(), float)
      assert acc.compute() == 0.5
  
      acc.reset()
      y_pred = torch.FloatTensor(
          [[0.4, 0.8, 0.2, 0.6], [0.8, 0.6, 0.4, 0.2]]
      )
      y = torch.ones(2).long()
      acc.update((y_pred, y))
      assert isinstance(acc.compute(), float)
      assert acc.compute() == 1.0
  
file_path: ignite/tests/ignite/metrics/test_top_k_categorical_accuracy.py
imports: import os
  import pytest
  import torch
  import ignite.distributed
  from ignite.exceptions import NotComputableError
  from ignite.metrics import TopKCategoricalAccuracy
label_desc: Use image node_id 2 for calling a global function with example usage: test_compute() without return types