class_docstr: A GPT-2 based nn.Sequential language model.
class_docstr_tok: ["A","GPT-2","based","nn.Sequential","language","model","."]
code: def __init__(
      self,
      ntokens,
      ninp,
      nhead,
      nhid,
      dropout,
      initrange,
      ndecoder,
      is_moe=False,
      num_local_experts=1,
  ):
      layers = [
          EmbeddingLayer(ntokens, ninp, initrange),
          PositionalEncodingLayer(ninp, dropout),
      ]
      for _ in range(ndecoder):
          layers.append(
              TransformerDecoderLayer(
                  ninp, nhead, nhid, dropout, is_moe, num_local_experts
              )
          )
  
      layers.append(LinearLayer(ninp, ntokens, initrange))
      super(TransformerLM, self).__init__(*layers)
  
imports: import math
  import torch
  import torch.nn
  from fairscale.nn.moe.moe_layer import MOELayer
  from fairscale.nn.moe.top2gate import Top2Gate
label_desc: Use image node_id 1 to create a new TransformerLM object from inherited base classes: nn with example: obj = TransformerLM(ntokens, ninp, nhead, nhid, dropout, initrange, ndecoder, is_moe, num_local_experts)