docstr: Alternate constructor.
docstr_tok: ["Alternate","constructor","."]
code: def from_opt(cls, opt, embeddings):
      """Alternate constructor."""
      return cls(
          opt.dec_layers,
          opt.dec_hid_size,
          opt.heads,
          opt.transformer_ff,
          opt.copy_attn,
          opt.self_attn_type,
          opt.dropout[0] if type(opt.dropout) is list else opt.dropout,
          opt.attention_dropout[0]
          if type(opt.attention_dropout) is list
          else opt.attention_dropout,
          embeddings,
          opt.max_relative_positions,
          opt.relative_positions_buckets,
          opt.aan_useffn,
          opt.full_context_alignment,
          opt.alignment_layer,
          alignment_heads=opt.alignment_heads,
          pos_ffn_activation_fn=opt.pos_ffn_activation_fn,
          add_qkvbias=opt.add_qkvbias,
          num_kv=opt.num_kv,
          add_ffnbias=opt.add_ffnbias,
          parallel_residual=opt.parallel_residual,
          shared_layer_norm=opt.shared_layer_norm,
          layer_norm=opt.layer_norm,
          norm_eps=opt.norm_eps,
          use_ckpting=opt.use_ckpting,
          parallel_gpu=opt.world_size
          if opt.parallel_mode == "tensor_parallel"
          else 1,
          sliding_window=opt.sliding_window,
          rotary_interleave=opt.rotary_interleave,
          rotary_theta=opt.rotary_theta,
          rotary_dim=opt.rotary_dim,
          num_experts=opt.num_experts,
          num_experts_per_tok=opt.num_experts_per_tok,
      )
  
imports: import torch
  import torch.nn
  from onmt.decoders.decoder import DecoderBase
  from onmt.modules import MultiHeadedAttention, AverageAttention
  from onmt.modules.position_ffn import PositionwiseFeedForward
  from onmt.modules.position_ffn import ActivationFunction
  from onmt.modules.moe import MoE
  from onmt.utils.misc import sequence_mask
  from onmt.modules.rmsnorm import RMSNorm
label_desc: Use image node_id 2 for calling the TransformerDecoderBase obj's underlying member method code with example usage: obj.from_opt(cls, opt, embeddings) and returns: cls