class_docstr: Takes in final states and returns distribution over candidates.
docstr: Initialize output layer.
  
  :param num_features:  number of candidates to rank
  :param hiddensize:    (last) dimension of the input vectors
  :param embeddingsize: (last) dimension of the candidate vectors
  :param numsoftmax:   (default 1) number of softmaxes to calculate.
                        see arxiv.org/abs/1711.03953 for more info.
                        increasing this slows down computation but can
                        add more expressivity to the embeddings.
  :param shared_weight: (num_features x esz) vector of weights to use as
                        the final linear layer's weight matrix. default
                        None starts with a new linear layer.
  :param padding_idx:   model should output a large negative number for
                        score at this index. if set to -1 (default),
                        this is disabled. if >= 0, subtracts one from
                        num_features and always outputs -1e20 at this
                        index. only used when shared_weight is not None.
                        setting this param helps protect gradient from
                        entering shared embedding matrices.
docstr_tok: ["Initialize","output","layer",".",":","param","num_features",":","number","of","candidates","to","rank",":","param","hiddensize",":","(","last",")","dimension","of","the","input","vectors",":","param","embeddingsize",":","(","last",")","dimension","of","the","candidate","vectors",":","param","numsoftmax",":","(","default","1",")","number","of","softmaxes","to","calculate",".","see","arxiv.org\/abs\/1711.03953","for","more","info",".","increasing","this","slows","down","computation","but","can","add","more","expressivity","to","the","embeddings",".",":","param","shared_weight",":","(","num_features","x","esz",")","vector","of","weights","to","use","as","the","final","linear","layer","'s","weight","matrix",".","default","None","starts","with","a","new","linear","layer",".",":","param","padding_idx",":","model","should","output","a","large","negative","number","for","score","at","this","index",".","if","set","to","-1","(","default",")",",","this","is","disabled",".","if",">","=","0",",","subtracts","one","from","num_features","and","always","outputs","-1e20","at","this","index",".","only","used","when","shared_weight","is","not","None",".","setting","this","param","helps","protect","gradient","from","entering","shared","embedding","matrices","."]
code: def __init__(
      self,
      num_features,
      embeddingsize,
      hiddensize,
      dropout=0,
      numsoftmax=1,
      shared_weight=None,
      padding_idx=-1,
  ):
      """
      Initialize output layer.
  
      :param num_features:  number of candidates to rank
      :param hiddensize:    (last) dimension of the input vectors
      :param embeddingsize: (last) dimension of the candidate vectors
      :param numsoftmax:   (default 1) number of softmaxes to calculate.
                            see arxiv.org/abs/1711.03953 for more info.
                            increasing this slows down computation but can
                            add more expressivity to the embeddings.
      :param shared_weight: (num_features x esz) vector of weights to use as
                            the final linear layer's weight matrix. default
                            None starts with a new linear layer.
      :param padding_idx:   model should output a large negative number for
                            score at this index. if set to -1 (default),
                            this is disabled. if >= 0, subtracts one from
                            num_features and always outputs -1e20 at this
                            index. only used when shared_weight is not None.
                            setting this param helps protect gradient from
                            entering shared embedding matrices.
      """
      super().__init__()
      self.dropout = nn.Dropout(p=dropout)
  
      self.padding_idx = padding_idx
      rng = 1.0 / math.sqrt(num_features)
      self.bias = Parameter(
          torch.Tensor(num_features).uniform_(-rng, rng)
      )
  
      # embedding to scores
      if shared_weight is None:
          # just a regular linear layer
          self.shared = False
          self.weight = Parameter(
              torch.Tensor(num_features, embeddingsize).normal_(0, 1)
          )
      else:
          # use shared weights and a bias layer instead
          self.shared = True
          self.weight = shared_weight.weight
  
      self.numsoftmax = numsoftmax
      if numsoftmax > 1:
          self.esz = embeddingsize
          self.softmax = nn.Softmax(dim=1)
          self.prior = nn.Linear(hiddensize, numsoftmax, bias=False)
          self.latent = nn.Linear(
              hiddensize, numsoftmax * embeddingsize
          )
          self.activation = nn.Tanh()
      else:
          # rnn output to embedding
          if hiddensize != embeddingsize:
              # learn projection to correct dimensions
              self.o2e = nn.Linear(hiddensize, embeddingsize, bias=True)
          else:
              # no need for any transformation here
              self.o2e = Identity()
  
imports: import math
  import torch
  import torch.nn
  from torch.nn.parameter import Parameter
  from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence
  import torch.nn.functional
  from parlai.utils.torch import neginf
  from parlai.core.torch_generator_agent import TorchGeneratorModel
label_desc: Use image node_id 1 to create a new OutputLayer object from inherited base classes: nn with example: obj = OutputLayer(num_features, embeddingsize, hiddensize, dropout, numsoftmax, shared_weight, padding_idx)