class_docstr: Helper class for adaptive embeddings specifying a cluster of tokens.
  
  Essentially a wrapper around a vocab embedding for the cluster with additional
  metadata so that we can apply the embedding to the actual ids and hidden
  states.
class_docstr_tok: ["Helper","class","for","adaptive","embeddings","specifying","a","cluster","of","tokens",".","Essentially","a","wrapper","around","a","vocab","embedding","for","the","cluster","with","additional","metadata","so","that","we","can","apply","the","embedding","to","the","actual","ids","and","hidden","states","."]
docstr: Cluster constructor.
  
  Args:
    embedding: a FactorizedVocabEmbedding or transformer.VocabEmbedding, the
      vocab embedding to use for the cluster.
    start_token_id: an integer, the inclusive id of the first token in the
      cluster.
    end_token_id: an integer, the exclusive id of the last token in the
      cluster.
    length_projection_factor: a float between 0 and 1, the sequence length
      dimension will be projected down to this number times the sequence
      length dimension to contain the elements in this cluster. If the input
      contains too many tokens in the cluster, tokens later in the input will
      be ignored.
    vocab_dim: an mtf.Dimension, the dimension the embedding uses as its
      vocab.
docstr_tok: ["Cluster","constructor",".","Args",":","embedding",":","a","FactorizedVocabEmbedding","or","transformer.VocabEmbedding",",","the","vocab","embedding","to","use","for","the","cluster",".","start_token_id",":","an","integer",",","the","inclusive","id","of","the","first","token","in","the","cluster",".","end_token_id",":","an","integer",",","the","exclusive","id","of","the","last","token","in","the","cluster",".","length_projection_factor",":","a","float","between","0","and","1",",","the","sequence","length","dimension","will","be","projected","down","to","this","number","times","the","sequence","length","dimension","to","contain","the","elements","in","this","cluster",".","If","the","input","contains","too","many","tokens","in","the","cluster",",","tokens","later","in","the","input","will","be","ignored",".","vocab_dim",":","an","mtf.Dimension",",","the","dimension","the","embedding","uses","as","its","vocab","."]
code: def __init__(
      self,
      embedding,
      start_token_id,
      end_token_id,
      length_projection_factor,
      vocab_dim,
  ):
      """Cluster constructor.
  
      Args:
        embedding: a FactorizedVocabEmbedding or transformer.VocabEmbedding, the
          vocab embedding to use for the cluster.
        start_token_id: an integer, the inclusive id of the first token in the
          cluster.
        end_token_id: an integer, the exclusive id of the last token in the
          cluster.
        length_projection_factor: a float between 0 and 1, the sequence length
          dimension will be projected down to this number times the sequence
          length dimension to contain the elements in this cluster. If the input
          contains too many tokens in the cluster, tokens later in the input will
          be ignored.
        vocab_dim: an mtf.Dimension, the dimension the embedding uses as its
          vocab.
      """
      self._embedding = embedding
      self._start_token_id = start_token_id
      self._end_token_id = end_token_id
      self._length_projection_factor = length_projection_factor
      self._vocab_dim = vocab_dim
  
imports: import math
  from typing import Dict, Sequence, Union
  import gin
  import mesh_tensorflow
  from mesh_tensorflow.transformer import transformer
  from mesh_tensorflow.transformer import vocab_embeddings
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
label_desc: Use image node_id 1 to create a new _Cluster object from inherited base classes: object with example: obj = _Cluster(embedding, start_token_id, end_token_id, length_projection_factor, vocab_dim)