class_docstr: Improved version over VectorQuantizer, can be used as a drop-in replacement. Mostly avoids costly matrix
  multiplications and allows for post-hoc remapping of indices.
class_docstr_tok: ["Improved","version","over","VectorQuantizer",",","can","be","used","as","a","drop-in","replacement",".","Mostly","avoids","costly","matrix","multiplications","and","allows","for","post-hoc","remapping","of","indices","."]
code: def remap_to_used(self, inds):
      ishape = inds.shape
      assert len(ishape) > 1
      inds = inds.reshape([ishape[0], -1])
      used = self.used
      match = (inds[:, :, None] == used[None, None, ...]).astype(
          "int64"
      )
      new = match.argmax(-1)
      unknown = match.sum(2) < 1
      if self.unknown_index == "random":
          new[unknown] = paddle.randint(
              0, self.re_embed, shape=new[unknown].shape
          )
      else:
          new[unknown] = self.unknown_index
      return new.reshape(ishape)
  
imports: import numpy
  import paddle
  import paddle.nn
  from ..configuration_utils import ConfigMixin
  from ..configuration_utils import register_to_config
  from .unet_blocks import get_down_block
  from .unet_blocks import get_up_block
  from .unet_blocks import UNetMidBlock2D
label_desc: Use image node_id 2 for calling the VectorQuantizer obj's underlying member method code with example usage: obj.remap_to_used(inds) and returns: new