code: def _assign_values_to_unbound_vars(unbound_vars, unbound_var_values):
    
    context = {}
    for key, value in six.iteritems(unbound_var_values):
      if key not in unbound_vars:
        raise ValueError('unexpected key: %s. Legal values are: %s' %
                         (key, list(six.iterkeys(unbound_vars))))
      context[unbound_vars[key]] = value
    unspecified = []
    for unbound_var in six.itervalues(unbound_vars):
      if unbound_var not in context:
        if unbound_var.has_default():
          context[unbound_var] = unbound_var.default
        else:
          unspecified.append(unbound_var.key)
    if unspecified:
      raise ValueError('Unspecified keys: %s' % unspecified)
    return context
docs: Assigns values to the vars and raises ValueError if one is missing.