class_docstr: Based on the default log_uniform_candidate_sampler in tensorflow.
  
  !!! NOTE
      num_words DOES NOT include padding id.
  
  !!! NOTE
      In all cases except (tie_embeddings=True and use_character_inputs=False)
      the weights are dimensioned as num_words and do not include an entry for the padding (0) id.
      For the (tie_embeddings=True and use_character_inputs=False) case,
      then the embeddings DO include the extra 0 padding, to be consistent with the word embedding layer.
  
  # Parameters
  
  num_words, `int`, required
      The number of words in the vocabulary
  embedding_dim, `int`, required
      The dimension to softmax over
  num_samples, `int`, required
      During training take this many samples. Must be less than num_words.
  sparse, `bool`, optional (default = `False`)
      If this is true, we use a sparse embedding matrix.
  unk_id, `int`, optional (default = `None`)
      If provided, the id that represents unknown characters.
  use_character_inputs, `bool`, optional (default = `True`)
      Whether to use character inputs
  use_fast_sampler, `bool`, optional (default = `False`)
      Whether to use the fast cython sampler.
class_docstr_tok: ["Based","on","the","default","log_uniform_candidate_sampler","in","tensorflow",".","!","!","!","NOTE","num_words","DOES","NOT","include","padding","id",".","!","!","!","NOTE","In","all","cases","except","(","tie_embeddings=True","and","use_character_inputs=False",")","the","weights","are","dimensioned","as","num_words","and","do","not","include","an","entry","for","the","padding","(","0",")","id",".","For","the","(","tie_embeddings=True","and","use_character_inputs=False",")","case",",","then","the","embeddings","DO","include","the","extra","0","padding",",","to","be","consistent","with","the","word","embedding","layer",".","#","Parameters","num_words",",","`","int","`",",","required","The","number","of","words","in","the","vocabulary","embedding_dim",",","`","int","`",",","required","The","dimension","to","softmax","over","num_samples",",","`","int","`",",","required","During","training","take","this","many","samples",".","Must","be","less","than","num_words",".","sparse",",","`","bool","`",",","optional","(","default","=","`","False","`",")","If","this","is","true",",","we","use","a","sparse","embedding","matrix",".","unk_id",",","`","int","`",",","optional","(","default","=","`","None","`",")","If","provided",",","the","id","that","represents","unknown","characters",".","use_character_inputs",",","`","bool","`",",","optional","(","default","=","`","True","`",")","Whether","to","use","character","inputs","use_fast_sampler",",","`","bool","`",",","optional","(","default","=","`","False","`",")","Whether","to","use","the","fast","cython","sampler","."]
code: def _forward_eval(
      self, embeddings: torch.Tensor, targets: torch.Tensor
  ) -> torch.Tensor:
      # evaluation mode, use full softmax
      if self.sparse:
          w = self.softmax_w.weight
          b = self.softmax_b.weight.squeeze(1)
      else:
          w = self.softmax_w
          b = self.softmax_b
  
      log_softmax = torch.nn.functional.log_softmax(
          torch.matmul(embeddings, w.t()) + b, dim=-1
      )
      if self.tie_embeddings and not self.use_character_inputs:
          targets_ = targets + 1
      else:
          targets_ = targets
      return torch.nn.functional.nll_loss(
          log_softmax, targets_.long(), reduction="sum"
      )
  
file_path: allennlp/allennlp/modules/sampled_softmax_loss.py
imports: from typing import Set, Tuple
  import numpy
  import torch
  from allennlp.common.checks import ConfigurationError
  from allennlp.nn import util
label_desc: Use image node_id 5 for calling the SampledSoftmaxLoss obj's underlying member method code with example usage: obj._forward_eval(embeddings, targets) and returns: torch