diff --git a/tensorflow_text/python/keras/layers/todense.py b/tensorflow_text/python/keras/layers/todense.py index 35eeebc60..df4e6dc4c 100644 --- a/tensorflow_text/python/keras/layers/todense.py +++ b/tensorflow_text/python/keras/layers/todense.py @@ -108,4 +108,8 @@ def get_config(self): 'shape': self._shape, } base_config = super(ToDense, self).get_config() - return dict(list(base_config.items()) + list(config.items())) + # Plain dict-merge instead of building two intermediate lists via + # list(...) + list(...) just to re-wrap them with dict(); same result + # (config's keys still take precedence on any overlap), no throwaway + # list allocations. + return {**base_config, **config}