class_docstr: Internal autograd-friendly call of a remote module. For applications, use RemoteExpert instead.
class_docstr_tok: ["Internal","autograd-friendly","call","of","a","remote","module",".","For","applications",",","use","RemoteExpert","instead","."]
code: def forward(
      ctx,
      dummy: torch.Tensor,
      uid: str,
      stub: "ConnectionHandlerStub",
      info: Dict[str, Any],
      *inputs: torch.Tensor,
  ) -> Tuple[torch.Tensor, ...]:
      # Note: *inputs are flattened input tensors that follow the expert's info['input_schema']
      # detach to avoid pickling the computation graph
      inputs = tuple(tensor.cpu().detach() for tensor in inputs)
      ctx.uid, ctx.stub, ctx.info = uid, stub, info
      ctx.save_for_backward(*inputs)
      serialized_tensors = (
          serialize_torch_tensor(tensor, proto.compression)
          for tensor, proto in zip(
              inputs, nested_flatten(info["forward_schema"])
          )
      )
      deserialized_outputs = RemoteExpertWorker.run_coroutine(
          expert_forward(uid, inputs, serialized_tensors, stub)
      )
  
      return tuple(deserialized_outputs)
  
imports: from __future__ import annotations
  from concurrent.futures import Future
  from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union
  import torch
  import torch.nn
  from torch.autograd.function import once_differentiable
  from hivemind import moe
  from hivemind.compression import deserialize_tensor_stream, deserialize_torch_tensor, serialize_torch_tensor
  from hivemind.dht import DHT
  from hivemind.moe.client.remote_expert_worker import RemoteExpertWorker
  from hivemind.moe.expert_uid import ExpertInfo
  from hivemind.p2p import P2P, PeerID, StubBase
  from hivemind.p2p.p2p_daemon_bindings.control import DEFAULT_MAX_MSG_SIZE, MAX_UNARY_PAYLOAD_SIZE
  from hivemind.proto import runtime_pb2
  from hivemind.utils.asyncio import amap_in_executor, iter_as_aiter
  from hivemind.utils.mpfuture import MPFuture
  from hivemind.utils.nested import nested_compare, nested_flatten, nested_pack
  from hivemind.utils.serializer import MSGPackSerializer
  from hivemind.utils.streaming import split_for_streaming
label_desc: Use image node_id 1 for calling the _RemoteModuleCall obj's underlying member method code with example usage: obj.forward(ctx, dummy, uid, stub, info) and returns: tuple