code: def construct_all(templates, **unbound_var_values):
    
  
    def _merge_dicts(src, dst):
      for k, v in six.iteritems(src):
        if dst.get(k, v) != v:
          raise ValueError('Conflicting values bound for %s: %s and %s' %
                           (k, v, dst[k]))
        else:
          dst[k] = v
    # pylint: disable=protected-access
    all_unbound_vars = {}
    context = {}
    for x in templates:
      if isinstance(x, _DeferredLayer):
        _merge_unbound_var_dicts(x.unbound_vars, all_unbound_vars)
        _merge_dicts(x._partial_context, context)
      else:
        raise TypeError('Unexpected type: %s' % type(x))
  
    _merge_dicts(
        _assign_values_to_unbound_vars(all_unbound_vars, unbound_var_values),
        context)
    # We need to create a result of known size to avoid client pylint errors.
    result = list(templates)
    for i, x in enumerate(result):
      if isinstance(x, _DeferredLayer):
        result[i] = x._construct(context)
    return result
docs: Constructs all the given templates in a single pass without redundancy.
  
    This is useful when the templates have a common substructure and you want the
    smallest possible graph.
  
    Args:
      templates: A sequence of templates.
      **unbound_var_values: The unbound_var values to replace.
    Returns:
      A list of results corresponding to templates.
    Raises:
      TypeError: If any value in templates is unsupported.
      ValueError: If the unbound_var values specified are not complete or contain
        unknown values.