code: def on_train_start(self, trainer, pl_module):
      if not trainer.use_ipex:
          warnings.warn(
              "CheckIPEXCallback is used, but ipex is disabled. "
          )
          return
      if TORCH_VERSION_LESS_1_10:
          from bigdl.nano.deps.ipex.version_1_9.ipex_torchfunctional import (
              RESTORE_TYPE,
          )
  
          def check_device(obj):
              if torch.is_tensor(obj):
                  if obj.device.type == "xpu":
                      return True
                  return False
              if isinstance(obj, RESTORE_TYPE):
                  iter_keys = (
                      obj.keys()
                      if isinstance(obj, Dict)
                      else range(len(obj))
                  )
                  for k in iter_keys:
                      if isinstance(obj[k], RESTORE_TYPE):
                          if not check_device(obj[k]):
                              return False
              return True
  
          assert check_device(pl_module.state_dict())
      else:
          from intel_extension_for_pytorch.nn.utils._model_convert import (
              _LSTM,
          )
          from intel_extension_for_pytorch.nn.utils._weight_prepack import (
              _IPEXConvNd,
              _IPEXLinear,
              _IPEXConvTransposeNd,
          )
  
          IPEX_LAYERS = (
              _LSTM,
              _IPEXConvNd,
              _IPEXLinear,
              _IPEXConvTransposeNd,
          )
          IPEX_ATTR = (
              "master_weight",
              "weight_trail",
              "master_bias",
              "bias_trail",
          )
  
          def check_ipex_layers(m):
              if isinstance(m, IPEX_LAYERS):
                  print("model is optimized by IPEX")
                  print(f"model contains layer {m}")
                  return True
              for attr in IPEX_ATTR:
                  if hasattr(m, attr):
                      return True
              for name, sub_m in m.named_children():
                  if check_ipex_layers(sub_m):
                      return True
              return False
  
          assert check_ipex_layers(pl_module)
  
file_path: BigDL/python/nano/test/pytorch/utils/_train_ipex_callback.py
imports: import operator
  import torch
  import warnings
  from typing import Dict
  import pytorch_lightning
  from pytorch_lightning.callbacks import Callback
  from pytorch_lightning.plugins.training_type import SingleDevicePlugin, DDPSpawnPlugin
  from pytorch_lightning.accelerators.cpu import CPUAccelerator
  from bigdl.nano.utils.pytorch import TORCH_VERSION_LESS_1_10
  from bigdl.nano.utils.common import _avx512_checker
  from bigdl.nano.utils.common import compare_version
label_desc: Use image node_id 1 for calling the CheckIPEXCallback obj's underlying member method code with example usage: obj.on_train_start(trainer, pl_module) and returns: True, False, False, True, True, True, True, False