class_docstr: Pytorch version >= 1.10 and <1.12, bfloat16 precision is supported.
  But there is no optimization on bfloat16.
code: def test_bf16_additional_attrs(self):
      model = resnet18(num_classes=10)
      x = torch.rand((10, 3, 256, 256))
      # patch a attribute
      model.channels = 3
  
      def hello():
          print("hello world!")
  
      # patch a function
      model.hello = hello
  
      # test bf16
      bf16_model = InferenceOptimizer.quantize(model, precision="bf16")
      with InferenceOptimizer.get_context(bf16_model):
          y_hat1 = bf16_model(x)
      assert y_hat1.shape == (10, 10) and y_hat1.dtype == torch.bfloat16
      assert bf16_model.channels == 3
      bf16_model.hello()
      with pytest.raises(
          AttributeError,
          match="'ResNet' object has no attribute 'strange_call'",
      ):
          bf16_model.strange_call()
  
      # test bf16 + channels_last
      bf16_model = InferenceOptimizer.quantize(
          model, precision="bf16", channels_last=True
      )
      with InferenceOptimizer.get_context(bf16_model):
          y_hat1 = bf16_model(x)
      assert y_hat1.shape == (10, 10) and y_hat1.dtype == torch.bfloat16
      assert bf16_model.channels == 3
      bf16_model.hello()
      with pytest.raises(AttributeError):
          bf16_model.width
  
      # save & load with original model
      with tempfile.TemporaryDirectory() as tmp_dir_name:
          InferenceOptimizer.save(bf16_model, tmp_dir_name)
          load_model = InferenceOptimizer.load(
              tmp_dir_name, model=model
          )
      assert load_model.channels == 3
      load_model.hello()
      with pytest.raises(
          AttributeError,
          match="'ResNet' object has no attribute 'strange_call'",
      ):
          load_model.strange_call()
  
imports: from unittest import TestCase
  import pytest
  import torch
  from bigdl.nano.pytorch import InferenceOptimizer
  from torchvision.models.resnet import resnet18
  from unittest.mock import MagicMock, PropertyMock, patch
  from bigdl.nano.utils.pytorch import TORCH_VERSION_LESS_1_12
  import tempfile
label_desc: Use image node_id 7 for calling the Pytorch1_12 obj's underlying member method code with example usage: obj.test_bf16_additional_attrs() without return types