docstr: Quantize the model during export with graph mode quantization.
docstr_tok: ["Quantize","the","model","during","export","with","graph","mode","quantization","."]
code: def graph_mode_quantize(
      self,
      inputs,
      data_loader,
      calibration_num_batches=64,
      qconfig_dict=None,
      force_quantize=False,
  ):
      """Quantize the model during export with graph mode quantization."""
      if force_quantize:
          trace = self.trace(inputs)
          if not qconfig_dict:
              qconfig_dict = {"": get_default_qconfig("fbgemm")}
          prepare_m = prepare_jit(trace, qconfig_dict, inplace=False)
          prepare_m.eval()
          with torch.no_grad():
              for i, (_, batch) in enumerate(data_loader):
                  print("Running calibration with batch {}".format(i))
                  input_data = self.onnx_trace_input(batch)
                  prepare_m(*input_data)
                  if i == calibration_num_batches - 1:
                      break
          trace = convert_jit(prepare_m, inplace=True)
      else:
          super().quantize()
          trace = self.trace(inputs)
  
      return trace
  
imports: import logging
  from typing import Dict, List, Optional, Tuple
  import torch
  from pytext import resources
  from pytext.common.constants import Stage, TORCH_VERSION
  from pytext.config import ConfigBase
  from pytext.data.roberta_tensorizer import RoBERTaTensorizer, RoBERTaTokenLevelTensorizer
  from pytext.data.tensorizers import FloatListTensorizer, LabelTensorizer, NumericLabelTensorizer, Tensorizer
  from pytext.models.bert_classification_models import NewBertModel
  from pytext.models.bert_regression_model import NewBertRegressionModel
  from pytext.models.decoders.mlp_decoder import MLPDecoder
  from pytext.models.model import BaseModel
  from pytext.models.module import create_module, Module
  from pytext.models.output_layers import WordTaggingOutputLayer
  from pytext.models.representations.transformer import MultiheadLinearAttention, PassthroughEncoder, PassthroughTransformer, PostEncoder, QuantizedMultiheadLinearAttention, SELFIETransformer, SentenceEncoder
  from pytext.models.representations.transformer_sentence_encoder_base import PoolingMethod, TransformerSentenceEncoderBase
  from pytext.models.utils import normalize_embeddings
  from pytext.torchscript.module import ScriptPyTextEmbeddingModuleIndex, ScriptPyTextModule, ScriptPyTextModuleWithDense
  from pytext.utils.file_io import PathManager
  from pytext.utils.usage import log_class_usage
  from pytorch.text.fb.nn.modules.multihead_attention import MultiheadSelfAttention
  from pytorch.text.fb.nn.modules.transformer import DEFAULT_MAX_SEQUENCE_LENGTH, Transformer, TransformerLayer
  from torch import nn
  from torch.serialization import default_restore_location
  from .r3f_models import R3FConfigOptions, R3FPyTextMixin
label_desc: Use image node_id 3 for calling the RoBERTa obj's underlying member method code with example usage: obj.graph_mode_quantize(inputs, data_loader, calibration_num_batches, qconfig_dict, force_quantize) and returns: trace