code: def test_compute_expert_scores():
      try:
          dht = DHT(start=True)
          moe = RemoteMixtureOfExperts(
              dht=dht,
              in_features=16,
              grid_size=(40,),
              k_best=4,
              k_min=1,
              timeout_after_k_min=1,
              uid_prefix="expert.",
          )
          gx, gy = torch.randn(4, 5, requires_grad=True), torch.randn(
              4, 3, requires_grad=True
          )
          ii = [[4, 0, 2], [3, 1, 1, 1, 3], [0], [3, 2]]
          jj = [[2, 2, 1], [0, 1, 2, 0, 1], [0], [1, 2]]
          batch_experts = [
              [
                  RemoteExpert(
                      ExpertInfo(
                          f"expert.{ii[batch_i][expert_i]}.{jj[batch_i][expert_i]}",
                          None,
                      ),
                      None,
                  )
                  for expert_i in range(len(ii[batch_i]))
              ]
              for batch_i in range(len(ii))
          ]  # note: these experts do not exist on server, we use them only to test compute_expert_scores
          logits = moe.compute_expert_scores([gx, gy], batch_experts)
          torch.softmax(logits, dim=-1).norm(dim=-1).mean().backward()
          assert (
              gx.grad.norm().item() > 0 and gy.grad.norm().item()
          ), "compute_expert_scores didn't backprop"
  
          for batch_i in range(len(ii)):
              for expert_i in range(len(ii[batch_i])):
                  assert torch.allclose(
                      logits[batch_i, expert_i],
                      gx[batch_i, ii[batch_i][expert_i]]
                      + gy[batch_i, jj[batch_i][expert_i]],
                  ), "compute_expert_scores returned incorrect score"
      finally:
          dht.shutdown()
  
imports: import asyncio
  import ctypes
  import multiprocessing
  import threading
  import time
  import numpy
  import pytest
  import torch
  from hivemind.dht import DHT
  from hivemind.moe.client.expert import RemoteExpert, create_remote_experts
  from hivemind.moe.client.moe import DUMMY, RemoteMixtureOfExperts, _RemoteCallMany
  from hivemind.moe.client.remote_expert_worker import RemoteExpertWorker
  from hivemind.moe.client.switch_moe import RemoteSwitchMixtureOfExperts
  from hivemind.moe.expert_uid import ExpertInfo
  from hivemind.moe.server import ModuleBackend, Server, background_server, declare_experts
  from hivemind.moe.server.layers import name_to_block
  from hivemind.p2p.p2p_daemon_bindings.control import P2PHandlerError
  from hivemind.utils import BatchTensorDescriptor, MPFuture, get_dht_time
label_desc: Use image node_id 7 for calling a global function with example usage: test_compute_expert_scores() without return types