class_docstr: Haiku module representing the VQ-VAE layer.
  
  Implements the algorithm presented in
  "Neural Discrete Representation Learning" by van den Oord et al.
  https://arxiv.org/abs/1711.00937
  
  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 - this variable is Beta).
class_docstr_tok: ["Haiku","module","representing","the","VQ-VAE","layer",".","Implements","the","algorithm","presented","in","''","Neural","Discrete","Representation","Learning","''","by","van","den","Oord","et","al",".","https",":","\/\/arxiv.org\/abs\/1711.00937","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","-","this","variable","is","Beta",")","."]
docstr: Returns embedding tensor for a batch of indices.
docstr_tok: ["Returns","embedding","tensor","for","a","batch","of","indices","."]
code: def quantize(self, encoding_indices):
      """Returns embedding tensor for a batch of indices."""
      w = self.embeddings.swapaxes(1, 0)
      w = jax.device_put(
          w
      )  # Required when embeddings is a NumPy array.
      return w[(encoding_indices,)]
  
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 4 for calling the VectorQuantizer obj's underlying member method code with example usage: obj.quantize(encoding_indices) and returns: w