class_docstr: Discrete bottleneck class.
class_docstr_tok: ["Discrete","bottleneck","class","."]
code: def __init__(self, hparams):
      self.hparams = hparams
      print("self.hparams.z_size", self.hparams.z_size)
      # Set the discretization bottleneck specific things here
      self.hparams.z_size_per_residual = (
          self.hparams.z_size // self.hparams.num_residuals
      )
      print("self.hparams.num_residuals", self.hparams.num_residuals)
      self.hparams.block_dim = int(
          self.hparams.hidden_size // self.hparams.num_blocks
      )
      self.hparams.block_v_size = 2 ** (
          self.hparams.z_size_per_residual / self.hparams.num_blocks
      )
      self.hparams.block_v_size = int(self.hparams.block_v_size)
      self.means = tf.get_variable(
          name="means",
          shape=[
              self.hparams.num_blocks,
              self.hparams.block_v_size,
              self.hparams.block_dim,
          ],
          initializer=tf.initializers.variance_scaling(
              distribution="uniform"
          ),
      )
  
      # Create the shadow variables if we are using EMA
      if self.hparams.ema:
          self.ema_count = tf.get_variable(
              "ema_count",
              [self.hparams.num_blocks, self.hparams.block_v_size],
              initializer=tf.constant_initializer(0),
              trainable=False,
          )
          with tf.colocate_with(self.means):
              self.ema_means = tf.get_variable(
                  "ema_means",
                  initializer=self.means.initialized_value(),
                  trainable=False,
              )
  
file_path: tensor2tensor/tensor2tensor/layers/vq_discrete.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from functools import partial
  from tensor2tensor.layers import common_layers
  import tensorflow.compat.v1
  from tensorflow.python.training import moving_averages
label_desc: Use image node_id 1 to create a new DiscreteBottleneck object from inherited base classes: object with example: obj = DiscreteBottleneck(hparams)