code: def forward(self, x):
      orig_shape = x.shape
      x = x.view(-1, x.shape[-1])
  
      scores = self.gate(x)
      if self.parallel_gpu > 1:
          all_reduce(scores)
      expert_weights, expert_indices = torch.topk(
          scores, self.num_experts_per_tok, dim=-1
      )
      expert_weights = expert_weights.softmax(dim=-1)
      flat_expert_indices = expert_indices.view(-1)
  
      x = x.repeat_interleave(self.num_experts_per_tok, dim=0)
      y = torch.empty_like(x)
      for i, expert in enumerate(self.experts):
          if torch.any(flat_expert_indices == i):
              y[flat_expert_indices == i] = expert(
                  x[flat_expert_indices == i]
              )
      y = (
          y.view(*expert_weights.shape, -1)
          * expert_weights.unsqueeze(-1)
      ).sum(dim=1)
      return y.view(*orig_shape)
  
file_path: OpenNMT-py/onmt/modules/moe.py
imports: import torch
  import torch.nn
  from onmt.modules.position_ffn import PositionwiseFeedForward
  from torch.distributed import all_reduce
label_desc: Use image node_id 2 for calling the MoE obj's underlying member method code with example usage: obj.forward(x) and returns: y