Understanding _DictWrapper

Dictionaries defined in a custom layer are automatically tracked by wrapping them in a dictionary wrapper object: _DictWrapper. I am interested in storing one such dictionary in a pickle file, but that is impossible when compiling my model with @tf.function. So I would like implement one of two approaches (which have failed so far):

  1. when I am about to print (from within a callback), simply extract the raw data from the wrapper. Somehow, the raw data must still be contained within this wrapper class. But there does not appear to be a built-in routine to do this. It is not clear why not.

  2. convert the wrapped dictionary into a regular dictionary. I am sure this is tricky once the graph is compiled, but surely there is a way to dump dictionaries to files for post processing?

Any other efficient approach would be acceptable. I just enumerated obvious methods that came to mind.

Thanks for any insights.