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 backward(
      ctx, *grad_outputs
  ) -> Tuple[Optional[torch.Tensor], ...]:
      grad_outputs_cpu = tuple(tensor.cpu() for tensor in grad_outputs)
      inputs_and_grad_outputs = tuple(
          nested_flatten((ctx.saved_tensors, grad_outputs_cpu))
      )
      backward_schema = tuple(
          nested_flatten(
              (ctx.info["forward_schema"], ctx.info["outputs_schema"])
          )
      )
      serialized_tensors = (
          serialize_torch_tensor(tensor, proto.compression)
          for tensor, proto in zip(
              inputs_and_grad_outputs, backward_schema
          )
      )
      deserialized_grad_inputs = RemoteExpertWorker.run_coroutine(
          expert_backward(
              ctx.uid,
              inputs_and_grad_outputs,
              serialized_tensors,
              ctx.stub,
          )
      )
  
      return (DUMMY, None, None, None, *deserialized_grad_inputs)
  
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 2 for calling the _RemoteModuleCall obj's underlying member method code with example usage: obj.backward(ctx) and returns: DUMMY,  None,  None,  None,  unknown