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.
code: def remap_to_used(self, inds):
      ishape = inds.shape
      assert len(ishape) > 1
      inds = inds.reshape(ishape[0], -1)
      used = self.used.to(inds)
      match = (inds[:, :, None] == used[None, None, ...]).long()
      new = match.argmax(-1)
      unknown = match.sum(2) < 1
      if self.unknown_index == "random":
          new[unknown] = torch.randint(
              0, self.re_embed, size=new[unknown].shape
          ).to(device=new.device)
      else:
          new[unknown] = self.unknown_index
      return new.reshape(ishape)
  
imports: from dataclasses import dataclass
  from typing import Optional
  import numpy
  import torch
  import torch.nn
  from ..utils import BaseOutput, is_torch_version
  from ..utils.torch_utils import randn_tensor
  from .activations import get_activation
  from .attention_processor import SpatialNorm
  from .unet_2d_blocks import AutoencoderTinyBlock, UNetMidBlock2D, get_down_block, get_up_block
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