do not get the finalizer when an extension is a lambda function
@@ -295,6 +295,9 @@ class Trainer(object):
entry.extension(self)
finally:
for _, entry in extensions:
+ if isinstance(entry.extension, types.FunctionType):
+ finalize = None
+ else:
finalize = entry.extension.finalize
if finalize:
finalize()
