code: def test_score_accuracy(n_tokens: int, n_experts: int) -> None:
      """
      Validate expert scores are correct.
      """
      logits = torch.randn(
          (n_tokens, n_experts),
          dtype=torch.float16,
          device=get_accelerator().current_device(),
      )
      batch = build_simple_batch([n_tokens], padding=False)
      n_top_k = 1
  
      gate = RaggedTopKGating(DtypeEnum.fp16)
  
      expert_counts = torch.zeros(
          (n_experts,),
          dtype=torch.int32,
          device=get_accelerator().current_device(),
      )
      scores = torch.empty(
          (n_tokens, n_top_k),
          dtype=torch.float32,
          device=get_accelerator().current_device(),
      )
      expert_assignment = torch.empty(
          (n_tokens, n_top_k),
          dtype=torch.int32,
          device=get_accelerator().current_device(),
      )
      expert_offset = torch.empty(
          (n_tokens, n_top_k),
          dtype=torch.int32,
          device=get_accelerator().current_device(),
      )
  
      ref_scores = F.softmax(logits.float(), dim=1).max(dim=1).values
      ref_scores = ref_scores.reshape(-1, 1)
  
      gate(
          expert_counts,
          scores,
          expert_assignment,
          expert_offset,
          logits,
          batch,
      )
  
      assert allclose(scores, ref_scores)
      assert expert_counts.sum() == n_tokens
  
file_path: DeepSpeed/tests/unit/inference/v2/kernels/ragged_ops/test_top_k_gating.py
imports: import pytest
  import torch
  import torch.nn.functional
  from deepspeed.accelerator import get_accelerator
  from deepspeed.inference.v2.inference_utils import DtypeEnum
  from deepspeed.inference.v2.kernels.ragged_ops import RaggedTopKGating
  from .ragged_testing_utils import build_simple_batch
  from ...inference_test_utils import allclose
label_desc: Use image node_id 7 for calling a global function with example usage: test_score_accuracy(n_tokens, n_experts) without return types