class_docstr: Dispatches input tensor [e, c, h] to all experts by all_to_all_single
  operation in torch.distributed.
class_docstr_tok: ["Dispatches","input","tensor","[","e",",","c",",","h","]","to","all","experts","by","all_to_all_single","operation","in","torch.distributed","."]
docstr: Returns:
      outputs: Tensor
      handle: Optional[Work], if overlap is True
docstr_tok: ["Returns",":","outputs",":","Tensor","handle",":","Optional","[","Work","]",",","if","overlap","is","True"]
code: def forward(
      ctx: Any,
      inputs: Tensor,
      group: ProcessGroup,
      overlap: bool = False,
  ) -> Tuple[Tensor, Any]:
      """
      Returns:
          outputs: Tensor
          handle: Optional[Work], if overlap is True
      """
      assert ctx is not None or not overlap
  
      if ctx is not None:
          ctx.comm_grp = group
      if not inputs.is_contiguous():
          inputs = inputs.contiguous()
      if dist.get_world_size(group) == 1:
          return inputs, None
      output = torch.empty_like(inputs)
      if not overlap:
          dist.all_to_all_single(output, inputs, group=group)
          return output, None
      else:
          handle = dist.all_to_all_single(
              output, inputs, group=group, async_op=True
          )
          return output, handle
  
imports: from typing import Any, Optional, Tuple
  import torch
  import torch.distributed
  from torch import Tensor
  from torch.cuda.amp import custom_bwd, custom_fwd
  from torch.distributed import ProcessGroup
label_desc: Use image node_id 1 for calling the AllToAll obj's underlying member method code with example usage: obj.forward(ctx, inputs, group, overlap) and returns: inputs,  None, output,  None, output,  handle