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: Trace a pytorch model and convert it into an accelerated module for inference.
  
  For example, this function returns a PytorchOpenVINOModel when accelerator=='openvino'.
  
  :param model: An torch.nn.Module model, including pl.LightningModule.
  :param input_sample: A set of inputs for trace, defaults to None if you have trace before or
                       model is a LightningModule with any dataloader attached.
  :param accelerator: The accelerator to use, defaults to None meaning staying in Pytorch
                      backend. 'openvino', 'onnxruntime' and 'jit' are supported for now.
  :param use_ipex: whether we use ipex as accelerator for inferencing. default: False.
  :param thread_num: (optional) a int represents how many threads(cores) is needed for
                     inference, only valid for accelerator='onnxruntime'
                     or accelerator='openvino'.
  :param onnxruntime_session_options: The session option for onnxruntime, only valid when
                                      accelerator='onnxruntime', otherwise will be ignored.
  :param logging: whether to log detailed information of model conversion, only valid when
                  accelerator='openvino', otherwise will be ignored. default: True.
  :param **kwargs: other extra advanced settings include
                   1. those be passed to torch.onnx.export function, only valid when
                   accelerator='onnxruntime'/'openvino', otherwise will be ignored.
                   2. if channels_last is set and use_ipex=True, we will transform the
                   data to be channels last according to the setting. Defaultly, channels_last
                   will be set to True if use_ipex=True.
  :return: Model with different acceleration.
  
  .. warning::
       ``bigdl.nano.pytorch.Trainer.trace`` will be deprecated in future release.
  
       Please use ``bigdl.nano.pytorch.InferenceOptimizer.trace`` instead.
docstr_tok: ["Trace","a","pytorch","model","and","convert","it","into","an","accelerated","module","for","inference",".","For","example",",","this","function","returns","a","PytorchOpenVINOModel","when","accelerator=='openvino","'",".",":","param","model",":","An","torch.nn.Module","model",",","including","pl.LightningModule",".",":","param","input_sample",":","A","set","of","inputs","for","trace",",","defaults","to","None","if","you","have","trace","before","or","model","is","a","LightningModule","with","any","dataloader","attached",".",":","param","accelerator",":","The","accelerator","to","use",",","defaults","to","None","meaning","staying","in","Pytorch","backend",".","'openvino","'",",","'onnxruntime","'","and","'jit","'","are","supported","for","now",".",":","param","use_ipex",":","whether","we","use","ipex","as","accelerator","for","inferencing",".","default",":","False",".",":","param","thread_num",":","(","optional",")","a","int","represents","how","many","threads","(","cores",")","is","needed","for","inference",",","only","valid","for","accelerator='onnxruntime'","or","accelerator='openvino","'",".",":","param","onnxruntime_session_options",":","The","session","option","for","onnxruntime",",","only","valid","when","accelerator='onnxruntime","'",",","otherwise","will","be","ignored",".",":","param","logging",":","whether","to","log","detailed","information","of","model","conversion",",","only","valid","when","accelerator='openvino","'",",","otherwise","will","be","ignored",".","default",":","True",".",":","param","*","*","kwargs",":","other","extra","advanced","settings","include","1.","those","be","passed","to","torch.onnx.export","function",",","only","valid","when","accelerator='onnxruntime'\/'openvino","'",",","otherwise","will","be","ignored",".","2.","if","channels_last","is","set","and","use_ipex=True",",","we","will","transform","the","data","to","be","channels","last","according","to","the","setting",".","Defaultly",",","channels_last","will","be","set","to","True","if","use_ipex=True",".",":","return",":","Model","with","different","acceleration",".","..","warning",":",":","``","bigdl.nano.pytorch.Trainer.trace","``","will","be","deprecated","in","future","release",".","Please","use","``","bigdl.nano.pytorch.InferenceOptimizer.trace","``","instead","."]
code: def trace(
      model: nn.Module,
      input_sample=None,
      accelerator: str = None,
      use_ipex: bool = False,
      thread_num: int = None,
      onnxruntime_session_options=None,
      logging: bool = True,
      **export_kwargs,
  ):
      """
      Trace a pytorch model and convert it into an accelerated module for inference.
  
      For example, this function returns a PytorchOpenVINOModel when accelerator=='openvino'.
  
      :param model: An torch.nn.Module model, including pl.LightningModule.
      :param input_sample: A set of inputs for trace, defaults to None if you have trace before or
                           model is a LightningModule with any dataloader attached.
      :param accelerator: The accelerator to use, defaults to None meaning staying in Pytorch
                          backend. 'openvino', 'onnxruntime' and 'jit' are supported for now.
      :param use_ipex: whether we use ipex as accelerator for inferencing. default: False.
      :param thread_num: (optional) a int represents how many threads(cores) is needed for
                         inference, only valid for accelerator='onnxruntime'
                         or accelerator='openvino'.
      :param onnxruntime_session_options: The session option for onnxruntime, only valid when
                                          accelerator='onnxruntime', otherwise will be ignored.
      :param logging: whether to log detailed information of model conversion, only valid when
                      accelerator='openvino', otherwise will be ignored. default: True.
      :param **kwargs: other extra advanced settings include
                       1. those be passed to torch.onnx.export function, only valid when
                       accelerator='onnxruntime'/'openvino', otherwise will be ignored.
                       2. if channels_last is set and use_ipex=True, we will transform the
                       data to be channels last according to the setting. Defaultly, channels_last
                       will be set to True if use_ipex=True.
      :return: Model with different acceleration.
  
      .. warning::
           ``bigdl.nano.pytorch.Trainer.trace`` will be deprecated in future release.
  
           Please use ``bigdl.nano.pytorch.InferenceOptimizer.trace`` instead.
      """
      return InferenceOptimizer.trace(
          model=model,
          input_sample=input_sample,
          accelerator=accelerator,
          use_ipex=use_ipex,
          thread_num=thread_num,
          onnxruntime_session_options=onnxruntime_session_options,
          logging=logging,
          **export_kwargs,
      )
  
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 6 for calling the Trainer obj's underlying member method code with example usage: obj.trace(model, input_sample, accelerator, use_ipex, thread_num, onnxruntime_session_options, logging) and returns: InferenceOptimizer