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: Ids to embeddings with ids not in cluster mapped to the zero vector.
docstr_tok: ["Ids","to","embeddings","with","ids","not","in","cluster","mapped","to","the","zero","vector","."]
code: def ids_to_embedding(self, ids, context):
      """Ids to embeddings with ids not in cluster mapped to the zero vector."""
      ids -= self._start_token_id
      # The mtf.gather in the embedding's ids_to_embedding implementation will
      # cause the one hot representations of tokens greater than cluster vocab
      # dimension size to be the zero vector. Thus the embeddings for those tokens
      # will be the zero vector.
      ids = mtf.where(
          mtf.greater_equal(ids, 0), ids, self._vocab_dim.size
      )
      # Handle the case of the head cluster where we will have entries at the end
      # corresponding to the tail clusters.
      ids = mtf.where(
          mtf.less(ids, self._end_token_id - self._start_token_id),
          ids,
          self._vocab_dim.size,
      )
      return self._embedding.ids_to_embedding(ids, context)
  
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 4 for calling the _Cluster obj's underlying member method code with example usage: obj.ids_to_embedding(ids, context) and returns: self