code: def test_attribute_access_after_trace(self):
      x = 100
      # for onnxruntime
      model = MyModel(x)
      traced_model = InferenceOptimizer.trace(
          model,
          accelerator="onnxruntime",
          input_spec=tf.TensorSpec(shape=(None, 4), dtype=tf.float32),
      )
      # try to access some custom attributes
      traced_model.do_nothing()
      assert traced_model.get_x() == traced_model.x == x
      traced_model(np.random.random((1, 4)).astype(np.float32))
  
      # test save/load with original model
      with tempfile.TemporaryDirectory() as tmp_dir_name:
          InferenceOptimizer.save(traced_model, tmp_dir_name)
          new_model = InferenceOptimizer.load(tmp_dir_name, model)
      new_model.do_nothing()
      assert new_model.get_x() == traced_model.x == x
  
      # test save/load without original model
      with tempfile.TemporaryDirectory() as tmp_dir_name:
          InferenceOptimizer.save(traced_model, tmp_dir_name)
          new_model = InferenceOptimizer.load(tmp_dir_name)
      with pytest.raises(AttributeError):
          new_model.do_nothing()
      with pytest.raises(AttributeError):
          assert new_model.get_x()
  
      # for openvino
      model = MyModel(x)
      traced_model = InferenceOptimizer.trace(
          model,
          accelerator="openvino",
          input_spec=tf.TensorSpec(shape=(None, 4), dtype=tf.float32),
      )
      # try to access some custom attributes
      traced_model.do_nothing()
      assert traced_model.get_x() == traced_model.x == x
      traced_model(np.random.random((1, 4)).astype(np.float32))
  
      # test save/load with original model
      with tempfile.TemporaryDirectory() as tmp_dir_name:
          InferenceOptimizer.save(traced_model, tmp_dir_name)
          new_model = InferenceOptimizer.load(tmp_dir_name, model)
      new_model.do_nothing()
      assert new_model.get_x() == traced_model.x == x
  
      # test save/load without original model
      with tempfile.TemporaryDirectory() as tmp_dir_name:
          InferenceOptimizer.save(traced_model, tmp_dir_name)
          new_model = InferenceOptimizer.load(tmp_dir_name)
      with pytest.raises(AttributeError):
          new_model.do_nothing()
      with pytest.raises(AttributeError):
          assert new_model.get_x()
  
imports: from unittest import TestCase
  import tempfile
  import operator
  import numpy
  import tensorflow
  import pytest
  from tensorflow.keras.metrics import MeanSquaredError, CategoricalAccuracy
  from tensorflow.keras import layers, Model
  from tensorflow.keras.applications import MobileNetV2
  from bigdl.nano.tf.keras import InferenceOptimizer
label_desc: Use image node_id 1 for calling the TestTraceAndQuantize obj's underlying member method code with example usage: obj.test_attribute_access_after_trace() without return types