class_docstr: Mixture of Experts Layer.
class_docstr_tok: ["Mixture","of","Experts","Layer","."]
code: def __init__(
      self,
      expert_x=8,
      expert_y=8,
      loss_coef=1e-2,
      hidden_size=4096,
      group_size=1024,
      capacity_factor_train=1.25,
      capacity_factor_eval=2.0,
      capacity_factor_second_level=1.0,
      use_second_place_loss=False,
      second_policy_train="random",
      second_policy_eval="random",
      second_threshold_train=0.2,
      second_threshold_eval=0.2,
  ):
      self._hparams = HParams(
          moe_gating="top_2",
          moe_num_experts=[expert_x, expert_y],
          moe_loss_coef=loss_coef,
          moe_hidden_size=hidden_size,
          moe_group_size=group_size,
          moe_capacity_factor_train=capacity_factor_train,
          moe_capacity_factor_eval=capacity_factor_eval,
          moe_capacity_factor_second_level=capacity_factor_second_level,
          moe_use_second_place_loss=use_second_place_loss,
          moe_second_policy_train=second_policy_train,
          moe_second_policy_eval=second_policy_eval,
          moe_second_threshold_train=second_threshold_train,
          moe_second_threshold_eval=second_threshold_eval,
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import gin
  import mesh_tensorflow
  from mesh_tensorflow.transformer import transformer
  import tensorflow.compat.v1
label_desc: Use image node_id 1 to create a new MoE2D object from inherited base classes: transformer with example: obj = MoE2D(expert_x, expert_y, loss_coef, hidden_size, group_size, capacity_factor_train, capacity_factor_eval, capacity_factor_second_level, use_second_place_loss, second_policy_train, second_policy_eval, second_threshold_train, second_threshold_eval)