code: def test_tf_nano_bf16_decorator():
      from bigdl.nano.tf import patch_tensorflow, unpatch_tensorflow
  
      patch_tensorflow(precision="mixed_bfloat16")
  
      class Model:
          model = Sequential([layers.Dense(units=1, input_shape=[1])])
          optimizer = keras.optimizers.Adam(learning_rate=0.001)
  
          def loss(self, y, pred):
              return tf.losses.mean_squared_error(y, pred)
  
          @nano_bf16
          @tf.function
          def train(self, x, y):
              with tf.GradientTape() as tape:
                  pred = self.model(x, training=True)
                  loss_value = self.loss(y, pred)
              grads = tape.gradient(
                  loss_value, self.model.trainable_variables
              )
              self.optimizer.apply_gradients(
                  zip(grads, self.model.trainable_variables)
              )
              return loss_value
  
      model = Model()
      # If call model.train() on devices without BF16 instruction set, core dumped
      # x = np.random.random(1000)
      # y = np.random.random(1000)
      # model.train(x, y)
      unpatch_tensorflow()
  
file_path: BigDL/python/nano/test/tf/train/test_tf_nano_decorator.py
imports: import tensorflow
  from tensorflow import keras
  from tensorflow.keras import layers
  from tensorflow.keras import backend
  from bigdl.nano.tf.keras import Sequential, nano_bf16
label_desc: Use image node_id 1 for calling a global function with example usage: test_tf_nano_bf16_decorator() and returns: tf, loss_value