class_docstr: Haiku module representing the VQ-VAE layer.
  
  Implements a slightly modified version of the algorithm presented in
  "Neural Discrete Representation Learning" by van den Oord et al.
  https://arxiv.org/abs/1711.00937
  
  The difference between :class:`VectorQuantizerEMA` and
  :class:`VectorQuantizer` is that this module uses
  :class:`~haiku.ExponentialMovingAverage`\ s to update the embedding vectors
  instead of an auxiliary loss. This has the advantage that the embedding
  updates are independent of the choice of optimizer (SGD, RMSProp, Adam, K-Fac,
  ...) used for the encoder, decoder and other parts of the architecture. For
  most experiments the EMA version trains faster than the non-EMA version.
  
  Input any tensor to be quantized. Last dimension will be used as space in
  which to quantize. All other dimensions will be flattened and will be seen
  as different examples to quantize.
  
  The output tensor will have the same shape as the input.
  
  For example a tensor with shape ``[16, 32, 32, 64]`` will be reshaped into
  ``[16384, 64]`` and all ``16384`` vectors (each of 64 dimensions)  will be
  quantized independently.
  
  Attributes:
    embedding_dim: integer representing the dimensionality of the tensors in
      the quantized space. Inputs to the modules must be in this format as well.
    num_embeddings: integer, the number of vectors in the quantized space.
    commitment_cost: scalar which controls the weighting of the loss terms
      (see equation 4 in the paper).
    decay: float, decay for the moving averages.
    epsilon: small float constant to avoid numerical instability.
class_docstr_tok: ["Haiku","module","representing","the","VQ-VAE","layer",".","Implements","a","slightly","modified","version","of","the","algorithm","presented","in","''","Neural","Discrete","Representation","Learning","''","by","van","den","Oord","et","al",".","https",":","\/\/arxiv.org\/abs\/1711.00937","The","difference","between",":","class",":","`","VectorQuantizerEMA","`","and",":","class",":","`","VectorQuantizer","`","is","that","this","module","uses",":","class",":","`","~haiku.ExponentialMovingAverage","`","\\","s","to","update","the","embedding","vectors","instead","of","an","auxiliary","loss",".","This","has","the","advantage","that","the","embedding","updates","are","independent","of","the","choice","of","optimizer","(","SGD",",","RMSProp",",","Adam",",","K-Fac",",","...",")","used","for","the","encoder",",","decoder","and","other","parts","of","the","architecture",".","For","most","experiments","the","EMA","version","trains","faster","than","the","non-EMA","version",".","Input","any","tensor","to","be","quantized",".","Last","dimension","will","be","used","as","space","in","which","to","quantize",".","All","other","dimensions","will","be","flattened","and","will","be","seen","as","different","examples","to","quantize",".","The","output","tensor","will","have","the","same","shape","as","the","input",".","For","example","a","tensor","with","shape","``","[","16",",","32",",","32",",","64","]","``","will","be","reshaped","into","``","[","16384",",","64","]","``","and","all","``","16384","``","vectors","(","each","of","64","dimensions",")","will","be","quantized","independently",".","Attributes",":","embedding_dim",":","integer","representing","the","dimensionality","of","the","tensors","in","the","quantized","space",".","Inputs","to","the","modules","must","be","in","this","format","as","well",".","num_embeddings",":","integer",",","the","number","of","vectors","in","the","quantized","space",".","commitment_cost",":","scalar","which","controls","the","weighting","of","the","loss","terms","(","see","equation","4","in","the","paper",")",".","decay",":","float",",","decay","for","the","moving","averages",".","epsilon",":","small","float","constant","to","avoid","numerical","instability","."]
code: def ema_cluster_size(self):
      self._ema_cluster_size.initialize(
          [self.num_embeddings], self._dtype
      )
      return self._ema_cluster_size
  
imports: from typing import Any, Optional
  from haiku._src import base
  from haiku._src import initializers
  from haiku._src import module
  from haiku._src import moving_averages
  import jax
  import jax.numpy
label_desc: Use image node_id 3 for calling the VectorQuantizerEMA obj's underlying member method code with example usage: obj.ema_cluster_size() and returns: self