code: def test_determinism(hidden_dim=16):
      atol = 1e-5
  
      xx = torch.randn(32, hidden_dim, requires_grad=True)
      mask = torch.randint(0, 1, (32, hidden_dim))
  
      with background_server(
          num_experts=1,
          device="cpu",
          expert_cls="det_dropout",
          num_handlers=1,
          hidden_dim=hidden_dim,
          optim_cls=None,
      ) as server_peer_info:
          dht = DHT(initial_peers=server_peer_info.addrs, start=True)
          expert = create_remote_experts(
              [
                  ExpertInfo(
                      uid="expert.0", peer_id=server_peer_info.peer_id
                  )
              ],
              dht=dht,
          )[0]
  
          out = expert(xx, mask)
          out_rerun = expert(xx, mask)
  
          (grad,) = torch.autograd.grad(
              out.sum(), xx, retain_graph=True
          )
          (grad_rerun,) = torch.autograd.grad(
              out_rerun.sum(), xx, retain_graph=True
          )
  
      assert torch.allclose(
          out, out_rerun, atol=atol, rtol=0
      ), "Dropout layer outputs are non-deterministic."
      assert torch.allclose(
          grad, grad_rerun, atol=atol, rtol=0
      ), "Gradients are non-deterministic."
  
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 6 for calling a global function with example usage: test_determinism(hidden_dim) without return types