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: Returns projection from length dim to the shorter cluster length dim.
docstr_tok: ["Returns","projection","from","length","dim","to","the","shorter","cluster","length","dim","."]
code: def get_project_to_cluster_length(self, cluster_mask, dtype):
      """Returns projection from length dim to the shorter cluster length dim."""
      seq_length_dim = cluster_mask.shape.get_dim_by_name("length")
      cluster_length_dim = self.get_cluster_length_dim(seq_length_dim)
      return mtf.cast(cluster_mask, dtype) * mtf.one_hot(
          mtf.cumsum(mtf.cast(cluster_mask, tf.int32), seq_length_dim)
          - 1,
          output_dim=cluster_length_dim,
          dtype=dtype,
      )
  
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 7 for calling the _Cluster obj's underlying member method code with example usage: obj.get_project_to_cluster_length(cluster_mask, dtype) and returns: unknown