From 50ed79312df18a361f4d4e635b5cfeb4f9290744 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 9 Jun 2023 13:11:01 +0100 Subject: [PATCH] Correctly build models and import call_context for older TF versions (#24138) --- src/transformers/modeling_tf_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/transformers/modeling_tf_utils.py b/src/transformers/modeling_tf_utils.py index 5127e4c9821b28..b23d2bae661053 100644 --- a/src/transformers/modeling_tf_utils.py +++ b/src/transformers/modeling_tf_utils.py @@ -81,7 +81,7 @@ from keras.engine.keras_tensor import KerasTensor else: from tensorflow.python.keras import backend as K - from tensorflow.python.keras.engine import call_context + from tensorflow.python.keras.engine.base_layer_utils import call_context from tensorflow.python.keras.engine.keras_tensor import KerasTensor @@ -1156,8 +1156,8 @@ def build(self, input_shape=None): if self.built or call_context().in_call: self.built = True else: - self(self.dummy_inputs, training=False) self.built = True + self(self.dummy_inputs, training=False) def __init__(self, config, *inputs, **kwargs): super().__init__(*inputs, **kwargs)