<s> import DeepFried2 as df <EOL> from itertools import chain as _chain <EOL> class ParallelCriterion ( df . Criterion ) : <EOL> def __init__ ( self , * weighted_criteria , ** kw ) : <EOL> """<STR_LIT>""" <EOL> df . Criterion . __init__ ( self ) <EOL> self . repeat_target = kw . get ( '<STR_LIT>' , False ) <EOL> self . criteria = [ ] <EOL> for wc in weighted_criteria : <EOL> self . add ( * df . utils . flatten ( wc ) ) <EOL> def add ( self , weight_or_crit , crit = None ) : <EOL> if crit is None : <EOL> self . criteria . append ( ( <NUM_LIT:1.0> , weight_or_crit ) ) <EOL> else : <EOL> self . criteria . append ( ( weight_or_crit , crit ) ) <EOL> def symb_forward ( self , symb_inputs , symb_targets ) : <EOL> symb_inputs = df . utils . flatten ( symb_inputs ) <EOL> symb_targets = df . utils . flatten ( symb_targets ) <EOL> if self . repeat_target : <EOL> symb_targets = symb_targets * len ( symb_inputs ) <EOL> assert len ( symb_inputs ) == len ( symb_targets ) == len ( self . criteria ) , "<STR_LIT>" . format ( df . utils . typename ( self ) , len ( symb_inputs ) , len ( self . criteria ) , len ( symb_targets ) ) <EOL> return sum ( w * c ( i , t ) for ( w , c ) , i , t in zip ( self . criteria , symb_inputs , symb_targets ) ) <EOL> def get_extra_outputs ( self ) : <EOL> return list ( _chain . from_iterable ( c . get_extra_outputs ( ) for ( w , c ) in self . criteria ) ) </s>
