class_docstr: Trainer for BigDL-Nano pytorch.
  
  This Trainer extends PyTorch Lightning Trainer by adding
  various options to accelerate pytorch training.
class_docstr_tok: ["Trainer","for","BigDL-Nano","pytorch",".","This","Trainer","extends","PyTorch","Lightning","Trainer","by","adding","various","options","to","accelerate","pytorch","training","."]
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.
         Only valid for inc ipex quantization model, otherwise will be ignored.
  :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.
  :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",".","Only","valid","for","inc","ipex","quantization","model",",","otherwise","will","be","ignored",".",":","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",".",":","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,
  ):
      """
      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.
             Only valid for inc ipex quantization model, otherwise will be ignored.
      :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.
      :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,
      )
  
imports: import copy
  from logging import warning
  from typing import Any, List, Optional, Union
  import pytorch_lightning
  import torch
  from torch import nn
  from torch.nn.modules.loss import _Loss
  from torch.utils.data import DataLoader
  from torchmetrics.metric import Metric
  from torch.optim.lr_scheduler import _LRScheduler
  from bigdl.nano.pytorch import InferenceOptimizer
  from bigdl.nano.utils.pytorch import TORCH_VERSION_LESS_1_11, check_ccl
  from bigdl.nano.utils.pytorch import ChannelsLastCallback
  from bigdl.nano.utils.pytorch import save_model, load_model
  from bigdl.nano.pytorch.algorithms import SelectiveBackprop
  from bigdl.nano.pytorch.lightning import LightningModule
  from bigdl.nano.pytorch.strategies import IPEXStrategy, DDPSpawnStrategy, DDPSubprocessStrategy, DDPK8sStrategy
  from bigdl.nano.deps.automl.hpo_api import create_hpo_searcher, check_hpo_status
  from bigdl.nano.deps.ray.ray_api import create_ray_strategy
  from bigdl.nano.utils.common import invalidInputError
  from bigdl.nano.utils.common import _avx512_checker
  from bigdl.nano.utils.common import deprecated
label_desc: Use image node_id 9 for calling the Trainer obj's underlying member method code with example usage: obj.load(path, model, input_sample, inplace, device) and returns: load_model