code: def assemble_common_meta(common_meta_dfs, fields_to_remove, sources, remove_all_metadata_fields, error_report_file):
      
      all_meta_df, all_meta_df_with_dups = build_common_all_meta_df(common_meta_dfs, fields_to_remove, remove_all_metadata_fields)
  
      if not all_meta_df.index.is_unique:
          all_report_df = build_mismatched_common_meta_report([x.shape for x in common_meta_dfs],
              sources, all_meta_df, all_meta_df_with_dups)
  
          unique_duplicate_ids = all_report_df.index.unique()
  
          if error_report_file is not None:
              all_report_df.to_csv(error_report_file, sep="\t")
  
          msg = """There are inconsistencies in common_metadata_df between different files.  Try excluding metadata fields
  using the fields_to_remove argument.  unique_duplicate_ids: {}
  all_report_df:
  {}""".format(unique_duplicate_ids, all_report_df)
          raise MismatchCommonMetadataConcatException(msg)
  
      # Finally, sort the index
      all_meta_df_sorted = all_meta_df.sort_index(axis=0)
  
      return all_meta_df_sorted
docs: Assemble the common metadata dfs together. Both indices are sorted.
      Fields that are not in all the dfs are dropped.
  
      Args:
          common_meta_dfs (list of pandas dfs)
          fields_to_remove (list of strings): fields to be removed from the
              common metadata because they don't agree across files
  
      Returns:
          all_meta_df_sorted (pandas df)