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 unmap_to_all(self, inds):
      ishape = inds.shape
      assert len(ishape) > 1
      inds = inds.reshape(ishape[0], -1)
      used = self.used.to(inds)
      if self.re_embed > self.used.shape[0]:  # extra token
          inds[inds >= self.used.shape[0]] = 0  # simply set to zero
      back = torch.gather(
          used[None, :][inds.shape[0] * [0], :], 1, inds
      )
      return back.reshape(ishape)
  
file_path: stable-diffusion-webui/extensions-builtin/LDSR/vqvae_quantize.py
imports: import torch
  import torch.nn
  import numpy
  from einops import rearrange
label_desc: Use image node_id 3 for calling the VectorQuantizer2 obj's underlying member method code with example usage: obj.unmap_to_all(inds) and returns: back