'Initializes the ComponentBuilder from specifications.
Args:
master: dragnn.MasterBuilder object.
component_spec: dragnn.ComponentSpec proto to be built.
attr_defaults: Optional dict of component attribute defaults.  If not
provided or if empty, attributes are not extracted.'

def __init__(self, master, component_spec, attr_defaults=None):

    self.master = master
    self.num_actions = component_spec.num_actions
    self.name = component_spec.name
    self.spec = component_spec
    self.moving_average = None
    self.eligible_for_self_norm = ((not self.master.hyperparams.self_norm_components_filter) or (self.name in self.master.hyperparams.self_norm_components_filter.split(',')))
    self._attrs = {}
    if attr_defaults:
        self._attrs = network_units.get_attrs_with_defaults(self.spec.component_builder.parameters, attr_defaults)
    with tf.variable_scope(self.name):
        self.training_beam_size = tf.constant(self.spec.training_beam_size, name='TrainingBeamSize')
        self.inference_beam_size = tf.constant(self.spec.inference_beam_size, name='InferenceBeamSize')
        self.locally_normalize = tf.constant(False, name='LocallyNormalize')
        self._step = tf.get_variable('step', [], initializer=tf.zeros_initializer(), dtype=tf.int32)
        self._total = tf.get_variable('total', [], initializer=tf.zeros_initializer(), dtype=tf.int32)
    self.network = self.make_network(self.spec.network_unit)
    if self.master.hyperparams.use_moving_average:
        self.moving_average = tf.train.ExponentialMovingAverage(decay=self.master.hyperparams.average_weight, num_updates=self._step)
        self.avg_ops = [self.moving_average.apply(self.network.params)]
