<s> try : <EOL> import cPickle as pickle <EOL> except ImportError : <EOL> import pickle <EOL> class Model ( object ) : <EOL> def __init__ ( self , arch , mixins ) : <EOL> self . arch = arch <EOL> self . mixins = { } <EOL> for mixin in mixins : <EOL> if isinstance ( mixin , type ) : <EOL> mixin = mixin ( ) <EOL> self . mixins [ mixin . name ] = ( mixin , mixin . priority ) <EOL> for mixin , priority in sorted ( self . mixins . values ( ) , key = lambda x : x [ <NUM_LIT:1> ] ) : <EOL> mixin . setup ( self ) <EOL> setattr ( self , mixin . name , mixin . get_function ( ) ) <EOL> def has_mixin ( self , name ) : <EOL> return name in self . mixins <EOL> def get_mixin ( self , name ) : <EOL> return self . mixins [ name ] [ <NUM_LIT:0> ] <EOL> def __str__ ( self ) : <EOL> return str ( self . arch ) <EOL> def save_parameters ( self , location ) : <EOL> state = self . arch . get_state ( ) <EOL> with open ( location , '<STR_LIT:wb>' ) as fp : <EOL> pickle . dump ( state , fp ) <EOL> def load_parameters ( self , location ) : <EOL> with open ( location , '<STR_LIT:rb>' ) as fp : <EOL> state = pickle . load ( fp ) <EOL> self . arch . load_state ( state ) </s>
