code: def quantize_generator(
      self, quantize=False, embed_quantize=EmbedQuantizeType.NONE
  ):
      if quantize:
          qconfig_dict = {
              torch.nn.Linear: tq.per_channel_dynamic_qconfig
          }
          # embedding quantization
          if embed_quantize != EmbedQuantizeType.NONE:
              # 8-bit embedding quantization
              if embed_quantize == EmbedQuantizeType.BIT_8:
                  qconfig_dict[
                      torch.nn.Embedding
                  ] = float_qparams_weight_only_qconfig
  
              # 4-bit embedding quantization
              elif embed_quantize == EmbedQuantizeType.BIT_4:
                  raise NotImplementedError(
                      "4bit embedding quantization not yet supported"
                  )
              else:
                  raise NotImplementedError(
                      "Embedding Quantization should be either 8bit or 4bit"
                  )
  
          self.model = tq.quantize_dynamic(
              self.model,
              qconfig_dict,
              dtype=torch.qint8,
              inplace=False,
          )
  
          self.length_prediction_model = tq.quantize_dynamic(
              self.length_prediction_model,
              {torch.nn.Linear: tq.per_channel_dynamic_qconfig},
              dtype=torch.qint8,
              inplace=False,
          )
  
imports: from enum import Enum
  from typing import Dict, Optional, Tuple
  import torch
  from pytext.common.constants import TORCH_VERSION
  from pytext.config import ConfigBase
  from pytext.models.module import Module
  from pytext.torchscript.vocab import ScriptVocabulary
  from torch import Tensor
label_desc: Use image node_id 4 for calling the MaskedSequenceGenerator obj's underlying member method code with example usage: obj.quantize_generator(quantize, embed_quantize) without return types