#NEWLINE# def add( self , key , item ) : #NEWLINE# #INDENT# " Add an item with a particular to the cache.\n\n        >>> tracker = Tracking()\n        >>> tracker.add('log_perplexity', 55.6)\n        >>> tracker.cache['log_perplexity']\n        [55.6]\n        >>> tracker.add('log_perplexity', 55.2)\n        >>> tracker.add('loss', -12.1)\n        >>> tracker.cache['log_perplexity']\n        [55.6, 55.2]\n        >>> tracker.cache['loss']\n        [-12.1]\n        " #NEWLINE# if ( key not in self . cache ) : #NEWLINE# #INDENT# self . cache [ key ] = [ ] #NEWLINE# #UNINDENT# self . cache [ key ] . append ( item ) #NEWLINE# if ( len ( self . cache [ key ] ) > self . n ) : #NEWLINE# #INDENT# self . cache [ key ] = self . cache [ key ] [ : self . n ]