code: def fields_from_names(fields, names=None):
      
  
      if names is None:
          return fields
      if isinstance(names, string_types):
          names = [names]
      aliases_to_names = aliases_from_fields(fields)
      names_to_aliases = dict(zip(aliases_to_names.values(),
          aliases_to_names.keys()))
      outfields = {}
      for name in names:
          try:
              outfields[name] = fields[name]
          except KeyError:
              if name in aliases_to_names:
                  key = (name, aliases_to_names[name])
              elif name in names_to_aliases:
                  key = (names_to_aliases[name], name)
              else:
                  raise KeyError('default fields has no field %s' % name)
              outfields[key] = fields[key]
      return outfields
docs: Given a dictionary of fields and a list of names, will return a
      dictionary consisting of the fields specified by names. Names can be
      either the names of fields, or their aliases.