[docs]@dataclassclassGarbageCollectorCallback(Callback):""" Disables automatic garbage collection during training and runs gen1 collection on a set schedule instead. .. important:: This callback gets added automatically in a distributed training setting if you don't explicitly configure it. If you want to override this callback you should subclass it. """gc_interval:int=1000enabled:bool=True_start_state:Optional[bool]=Nonedefpre_train(self):ifnotself.enabled:returnself._start_state=gc.isenabled()gc.disable()log.info(f"Automatic GC disabled for training, will run GC every {self.gc_interval} steps")defpost_step(self):ifnotself.enabled:returnifself.step%self.gc_interval==0:ifself.gc_interval>10:log.info("Running garbage collection")gc.collect(1)defclose(self):ifnotself.enabled:returnifself._start_state:gc.enable()defpost_checkpoint_saved(self,path:PathOrStr):delpathifnotself.enabled:returngc.collect(1)