code: def __init__(
      self,
      input_dim: int,
      n_codes: int,
      codebook_dim: int,
      beta: float = 1.0,
      output_dim: Optional[int] = None,
      **kwargs,
  ):
      super().__init__(n_codes, codebook_dim, beta, **kwargs)
      self.proj_in = nn.Linear(input_dim, codebook_dim)
      self.output_dim = output_dim
      if output_dim is not None:
          self.proj_out = nn.Linear(codebook_dim, output_dim)
      else:
          self.proj_out = nn.Identity()
  
imports: import logging
  from abc import abstractmethod
  from typing import Dict, Iterator, Literal, Optional, Tuple, Union
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from einops import rearrange
  from torch import einsum
  from .base import AbstractRegularizer, measure_perplexity
label_desc: Use image node_id 1 to create a new VectorQuantizerWithInputProjection object from inherited base classes: VectorQuantizer with example: obj = VectorQuantizerWithInputProjection(input_dim, n_codes, codebook_dim, beta, output_dim)