class_docstr: Helper for implementing a mixture of experts.
  
  A TruncatingDispatcher is useful when you need to deal with
  fixed-sized Tensors.  As opposed to a SparseDispatcher, which
  produces batches of different sizes for the different experts, the
  TruncatingDispatcher always produces batches of the same given size,
  and the results are returned stacked in one big tensor.
  
  In the case where an expert is over-capacity, the last items that
  should have gone to that expert are dropped.
  
  Confusingly, the inputs to a TruncatingDispatcher have both a
  "batch" and a "length" dimension.  Not only does each expert receive
  the same total number of examples, it also receives the same number
  of examples for each element of "batch".  This behavior is necessary
  for applications such as grouped attention, where we have a batch of
  sequences, and we want each sequence to be divided evenly among
  experts.  For simpler applications like mixture-of-experts, you can
  reshape the input so that the "batch" dimension is 1, and only the
  "length" dimension is used.
class_docstr_tok: ["Helper","for","implementing","a","mixture","of","experts",".","A","TruncatingDispatcher","is","useful","when","you","need","to","deal","with","fixed-sized","Tensors",".","As","opposed","to","a","SparseDispatcher",",","which","produces","batches","of","different","sizes","for","the","different","experts",",","the","TruncatingDispatcher","always","produces","batches","of","the","same","given","size",",","and","the","results","are","returned","stacked","in","one","big","tensor",".","In","the","case","where","an","expert","is","over-capacity",",","the","last","items","that","should","have","gone","to","that","expert","are","dropped",".","Confusingly",",","the","inputs","to","a","TruncatingDispatcher","have","both","a","''","batch","''","and","a","``","length","''","dimension",".","Not","only","does","each","expert","receive","the","same","total","number","of","examples",",","it","also","receives","the","same","number","of","examples","for","each","element","of","``","batch","''",".","This","behavior","is","necessary","for","applications","such","as","grouped","attention",",","where","we","have","a","batch","of","sequences",",","and","we","want","each","sequence","to","be","divided","evenly","among","experts",".","For","simpler","applications","like","mixture-of-experts",",","you","can","reshape","the","input","so","that","the","``","batch","''","dimension","is","1",",","and","only","the","''","length","''","dimension","is","used","."]
docstr: Length coordinate of dispatched tensor.
  
  Returns:
    a tensor with shape [batch, num_experts, expert_capacity] containing
     integers in the range [0, length)
docstr_tok: ["Length","coordinate","of","dispatched","tensor",".","Returns",":","a","tensor","with","shape","[","batch",",","num_experts",",","expert_capacity","]","containing","integers","in","the","range","[","0",",","length",")"]
code: def length_coordinate(self):
      """Length coordinate of dispatched tensor.
  
      Returns:
        a tensor with shape [batch, num_experts, expert_capacity] containing
         integers in the range [0, length)
      """
      return self._indices
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import math
  import six
  from six.moves import range
  from six.moves import zip
  from tensor2tensor.layers import common_layers
  from tensor2tensor.layers.vq_discrete import DiscreteBottleneck
  import tensorflow.compat.v1
label_desc: Use image node_id 6 for calling the TruncatingDispatcher obj's underlying member method code with example usage: obj.length_coordinate() and returns: self