class_docstr: A helper for use during inference.
  
  Samples from `top_k` most likely candidates from a vocab distribution,
  and passes the result through an embedding layer to get the next input.
class_docstr_tok: ["A","helper","for","use","during","inference",".","Samples","from","`","top_k","`","most","likely","candidates","from","a","vocab","distribution",",","and","passes","the","result","through","an","embedding","layer","to","get","the","next","input","."]
docstr: Initializer.
  
  Args:
      embedding: A callable or the `params` argument for
          `embedding_lookup`. If a callable, it can take a vector tensor
          of token `ids`, or take two arguments (`ids`, `times`),
          where `ids` is a vector
          tensor of token ids, and `times` is a vector tensor of current
          time steps (i.e., position ids). The latter case can be used
          when attr:`embedding` is a combination of word embedding and
          position embedding.
      start_tokens: `int32` vector shaped `[batch_size]`, the start
          tokens.
      end_token: `int32` scalar, the token that marks end of decoding.
      top_k: `int32` scalar tensor. Number of top candidates to sample
          from. Must be `>=0`. If set to 0, samples from all candidates
          (i.e., regular random sample decoding).
      softmax_temperature (optional): `float32` scalar, value to
          divide the logits by before computing the softmax. Larger values
          (above 1.0) result in more random samples, while smaller values
          push the sampling distribution towards the argmax. Must be
          strictly greater than 0. Defaults to 1.0.
      seed (optional): The sampling seed.
  
  Raises:
      ValueError: if `start_tokens` is not a 1D tensor or `end_token` is
      not a scalar.
docstr_tok: ["Initializer",".","Args",":","embedding",":","A","callable","or","the","`","params","`","argument","for","`","embedding_lookup","`",".","If","a","callable",",","it","can","take","a","vector","tensor","of","token","`","ids","`",",","or","take","two","arguments","(","`","ids","`",",","`","times","`",")",",","where","`","ids","`","is","a","vector","tensor","of","token","ids",",","and","`","times","`","is","a","vector","tensor","of","current","time","steps","(","i.e.",",","position","ids",")",".","The","latter","case","can","be","used","when","attr",":","`","embedding","`","is","a","combination","of","word","embedding","and","position","embedding",".","start_tokens",":","`","int32","`","vector","shaped","`","[","batch_size","]","`",",","the","start","tokens",".","end_token",":","`","int32","`","scalar",",","the","token","that","marks","end","of","decoding",".","top_k",":","`","int32","`","scalar","tensor",".","Number","of","top","candidates","to","sample","from",".","Must","be","`",">","=0","`",".","If","set","to","0",",","samples","from","all","candidates","(","i.e.",",","regular","random","sample","decoding",")",".","softmax_temperature","(","optional",")",":","`","float32","`","scalar",",","value","to","divide","the","logits","by","before","computing","the","softmax",".","Larger","values","(","above","1.0",")","result","in","more","random","samples",",","while","smaller","values","push","the","sampling","distribution","towards","the","argmax",".","Must","be","strictly","greater","than","0",".","Defaults","to","1.0.","seed","(","optional",")",":","The","sampling","seed",".","Raises",":","ValueError",":","if","`","start_tokens","`","is","not","a","1D","tensor","or","`","end_token","`","is","not","a","scalar","."]
code: def __init__(
      self,
      embedding,
      start_tokens,
      end_token,
      top_k=10,
      softmax_temperature=None,
      seed=None,
  ):
      """Initializer.
  
      Args:
          embedding: A callable or the `params` argument for
              `embedding_lookup`. If a callable, it can take a vector tensor
              of token `ids`, or take two arguments (`ids`, `times`),
              where `ids` is a vector
              tensor of token ids, and `times` is a vector tensor of current
              time steps (i.e., position ids). The latter case can be used
              when attr:`embedding` is a combination of word embedding and
              position embedding.
          start_tokens: `int32` vector shaped `[batch_size]`, the start
              tokens.
          end_token: `int32` scalar, the token that marks end of decoding.
          top_k: `int32` scalar tensor. Number of top candidates to sample
              from. Must be `>=0`. If set to 0, samples from all candidates
              (i.e., regular random sample decoding).
          softmax_temperature (optional): `float32` scalar, value to
              divide the logits by before computing the softmax. Larger values
              (above 1.0) result in more random samples, while smaller values
              push the sampling distribution towards the argmax. Must be
              strictly greater than 0. Defaults to 1.0.
          seed (optional): The sampling seed.
  
      Raises:
          ValueError: if `start_tokens` is not a 1D tensor or `end_token` is
          not a scalar.
      """
      super(TopKSampleEmbeddingHelper, self).__init__(
          embedding, start_tokens, end_token
      )
      self._top_k = top_k
      self._softmax_temperature = softmax_temperature
      self._seed = seed
  
imports: import tensorflow
  from tensorflow.python.ops import array_ops
  from tensorflow_probability import distributions
  from texar.tf.modules.decoders.tf_helpers import Helper, TrainingHelper, GreedyEmbeddingHelper
  from texar.tf.modules.embedders.embedder_utils import soft_embedding_lookup
  from texar.tf.utils import utils
label_desc: Use image node_id 1 to create a new TopKSampleEmbeddingHelper object from inherited base classes: GreedyEmbeddingHelper with example: obj = TopKSampleEmbeddingHelper(embedding, start_tokens, end_token, top_k, softmax_temperature, seed)