docstr: Load a model from local.
  
  :param path: Path to model to be loaded. Path should be a directory.
  :param model: Required FP32 model to load pytorch model, it is needed if:
         1. you accelerate the model with accelerator=None by
         InferenceOptimizer.trace()/InferenceOptimizer.quantize().
         2. you accelerate the model with InferenceOptimizer.optimize() and
         get_model()/get_best_model(), and the best method or the method you
         specify don't contain accelerator 'onnxruntime'/'openvino'/'jit'.
         If you are not sure what optimization method is used, we recommend that
         you always pass in the original model for this case.
         3. you want to the loaded model contains the attributes of original model.
  :param input_sample: Input sample for your model, could be a Tensor or a tuple.
         This parameter is needed if:
         1. saving model is accelerated by INC IPEX quantization.
         2. saving model is accelerated by JIT and you set compression='bf16'
         when saving.
  :param inplace: whether to perform inplace optimization. Default: ``False``.
  :param device: A string represents the device of the inference. Default to None.
         Only valid for openvino model, otherwise will be ignored.
  :param cache_dir: A directory for OpenVINO to cache the model. Default to None.
         Only valid for openvino model, otherwise will be ignored.
  :param shapes: input shape. For example, 'input1[1,3,224,224],input2[1,4]',
         '[1,3,224,224]'. This parameter affect model Parameter shape, can be
         dynamic. For dynamic dimesions use symbol `?`, `-1` or range `low.. up`.'.
         Default to None, which means you don't want to reshape the model inputs.
         Only valid for openvino model, otherwise will be ignored.
  :return: Model with different acceleration(None/OpenVINO/ONNX Runtime/JIT) or
           precision(FP32/FP16/BF16/INT8).
docstr_tok: ["Load","a","model","from","local",".",":","param","path",":","Path","to","model","to","be","loaded",".","Path","should","be","a","directory",".",":","param","model",":","Required","FP32","model","to","load","pytorch","model",",","it","is","needed","if",":","1.","you","accelerate","the","model","with","accelerator=None","by","InferenceOptimizer.trace","(",")","\/InferenceOptimizer.quantize","(",")",".","2.","you","accelerate","the","model","with","InferenceOptimizer.optimize","(",")","and","get_model","(",")","\/get_best_model","(",")",",","and","the","best","method","or","the","method","you","specify","do","n't","contain","accelerator","'onnxruntime'\/'openvino'\/'jit","'",".","If","you","are","not","sure","what","optimization","method","is","used",",","we","recommend","that","you","always","pass","in","the","original","model","for","this","case",".","3.","you","want","to","the","loaded","model","contains","the","attributes","of","original","model",".",":","param","input_sample",":","Input","sample","for","your","model",",","could","be","a","Tensor","or","a","tuple",".","This","parameter","is","needed","if",":","1.","saving","model","is","accelerated","by","INC","IPEX","quantization",".","2.","saving","model","is","accelerated","by","JIT","and","you","set","compression='bf16'","when","saving",".",":","param","inplace",":","whether","to","perform","inplace","optimization",".","Default",":","``","False","``",".",":","param","device",":","A","string","represents","the","device","of","the","inference",".","Default","to","None",".","Only","valid","for","openvino","model",",","otherwise","will","be","ignored",".",":","param","cache_dir",":","A","directory","for","OpenVINO","to","cache","the","model",".","Default","to","None",".","Only","valid","for","openvino","model",",","otherwise","will","be","ignored",".",":","param","shapes",":","input","shape",".","For","example",",","'input1","[","1,3,224,224","]",",","input2","[","1,4","]","'",",","'","[","1,3,224,224","]","'",".","This","parameter","affect","model","Parameter","shape",",","can","be","dynamic",".","For","dynamic","dimesions","use","symbol","`","?","`",",","`","-1","`","or","range","`","low","..","up","`",".","'",".","Default","to","None",",","which","means","you","do","n't","want","to","reshape","the","model","inputs",".","Only","valid","for","openvino","model",",","otherwise","will","be","ignored",".",":","return",":","Model","with","different","acceleration","(","None\/OpenVINO\/ONNX","Runtime\/JIT",")","or","precision","(","FP32\/FP16\/BF16\/INT8",")","."]
code: def load(
      path,
      model: Optional[nn.Module] = None,
      input_sample=None,
      inplace=False,
      device=None,
      cache_dir=None,
      shapes=None,
  ):
      """
      Load a model from local.
  
      :param path: Path to model to be loaded. Path should be a directory.
      :param model: Required FP32 model to load pytorch model, it is needed if:
             1. you accelerate the model with accelerator=None by
             InferenceOptimizer.trace()/InferenceOptimizer.quantize().
             2. you accelerate the model with InferenceOptimizer.optimize() and
             get_model()/get_best_model(), and the best method or the method you
             specify don't contain accelerator 'onnxruntime'/'openvino'/'jit'.
             If you are not sure what optimization method is used, we recommend that
             you always pass in the original model for this case.
             3. you want to the loaded model contains the attributes of original model.
      :param input_sample: Input sample for your model, could be a Tensor or a tuple.
             This parameter is needed if:
             1. saving model is accelerated by INC IPEX quantization.
             2. saving model is accelerated by JIT and you set compression='bf16'
             when saving.
      :param inplace: whether to perform inplace optimization. Default: ``False``.
      :param device: A string represents the device of the inference. Default to None.
             Only valid for openvino model, otherwise will be ignored.
      :param cache_dir: A directory for OpenVINO to cache the model. Default to None.
             Only valid for openvino model, otherwise will be ignored.
      :param shapes: input shape. For example, 'input1[1,3,224,224],input2[1,4]',
             '[1,3,224,224]'. This parameter affect model Parameter shape, can be
             dynamic. For dynamic dimesions use symbol `?`, `-1` or range `low.. up`.'.
             Default to None, which means you don't want to reshape the model inputs.
             Only valid for openvino model, otherwise will be ignored.
      :return: Model with different acceleration(None/OpenVINO/ONNX Runtime/JIT) or
               precision(FP32/FP16/BF16/INT8).
      """
      return load_model(
          path,
          model,
          input_sample=input_sample,
          inplace=inplace,
          device=device,
          cache_dir=cache_dir,
          shapes=shapes,
      )
  
imports: import torch
  from torch import nn
  import time
  import sigfig
  import multiprocessing
  from typing import Dict, Callable, Tuple, Optional, List, Union, Sequence, Mapping
  from torch.utils.data import DataLoader
  from torchmetrics.metric import Metric
  from bigdl.nano.utils.common import AccelerationOption, available_acceleration_combination, latency_calculate_helper, torch_loader_latency_calculate_helper, format_optimize_result, BaseInferenceOptimizer
  from bigdl.nano.utils.common import invalidInputError
  from bigdl.nano.pytorch.amp import BF16Model
  from bigdl.nano.pytorch.low_precision.jit_int8_api import PytorchJITINT8Model
  from bigdl.nano.deps.openvino.openvino_api import PytorchOpenVINOModel
  from bigdl.nano.deps.ipex.ipex_api import PytorchIPEXJITModel, PytorchIPEXJITBF16Model, PytorchIPEXQuantizationModel, PytorchIPEXPUModel
  from bigdl.nano.deps.onnxruntime.onnxruntime_api import PytorchONNXRuntimeModel
  from bigdl.nano.deps.neural_compressor.inc_api import quantize
  from bigdl.nano.pytorch.model import AcceleratedLightningModule
  from bigdl.nano.utils.pytorch import get_forward_args, get_input_example
  from bigdl.nano.utils.pytorch import NanoMetric
  from bigdl.nano.utils.pytorch import RepeatDataset, remove_batch_dim_fn
  from bigdl.nano.utils.pytorch import transform_multiple_input_dataloader_to_inc_mode, automatic_add_label_in_dataloader
  from bigdl.nano.utils.pytorch import TORCH_VERSION_LESS_1_10
  from bigdl.nano.utils.pytorch import save_model, load_model
  from bigdl.nano.utils.common import schedule_processors
  from bigdl.nano.utils.common import EnvContext
  from bigdl.nano.pytorch.context_manager import generate_context_manager, BaseContextManager, AutocastContextManager
  from .multi_instance import _MultiInstanceModel, _multi_instance_helper
  import traceback
  import warnings
  import os
label_desc: Use image node_id 6 for calling the InferenceOptimizer obj's underlying member method code with example usage: obj.load(path, model, input_sample, inplace, device, cache_dir, shapes) and returns: load_model