code: def generate_inputs_and_wrap_model(
      config_path, checkpoint_path, input_config
  ):
      """Prepare sample input and wrap model for ONNX export.
  
      The ONNX export API only accept args, and all inputs should be
      torch.Tensor or corresponding types (such as tuple of tensor).
      So we should call this function before exporting. This function will:
  
      1. generate corresponding inputs which are used to execute the model.
      2. Wrap the model's forward function.
  
      For example, the MMDet models' forward function has a parameter
      ``return_loss:bool``. As we want to set it as False while export API
      supports neither bool type or kwargs. So we have to replace the forward
      like: ``model.forward = partial(model.forward, return_loss=False)``
  
      Args:
          config_path (str): the OpenMMLab config for the model we want to
              export to ONNX
          checkpoint_path (str): Path to the corresponding checkpoint
          input_config (dict): the exactly data in this dict depends on the
              framework. For MMSeg, we can just declare the input shape,
              and generate the dummy data accordingly. However, for MMDet,
              we may pass the real img path, or the NMS will return None
              as there is no legal bbox.
  
      Returns:
          tuple: (model, tensor_data) wrapped model which can be called by \
          model(*tensor_data) and a list of inputs which are used to execute \
              the model while exporting.
      """
  
      model = build_model_from_cfg(config_path, checkpoint_path)
      one_img, one_meta = preprocess_example_input(input_config)
      tensor_data = [one_img]
      model.forward = partial(
          model.forward, img_metas=[[one_meta]], return_loss=False
      )
  
      # pytorch has some bug in pytorch1.3, we have to fix it
      # by replacing these existing op
      opset_version = 11
      # put the import within the function thus it will not cause import error
      # when not using this function
      try:
          from mmcv.onnx.symbolic import register_extra_symbolics
      except ModuleNotFoundError:
          raise NotImplementedError(
              "please update mmcv to version>=v1.0.4"
          )
      register_extra_symbolics(opset_version)
  
      return model, tensor_data
  
file_path: insightface/detection/scrfd/mmdet/core/export/pytorch2onnx.py
imports: from functools import partial
  import mmcv
  import numpy
  import torch
  from mmcv.runner import load_checkpoint
label_desc: Use image node_id 1 for calling a global function with example usage: generate_inputs_and_wrap_model(config_path, checkpoint_path, input_config) and returns: model,  tensor_data