code: def save_base_map(filename, grouped_by_text):
      
      rows = []
      for group in grouped_by_text:
          text_string = group[0]
          for db, db_id, count in group[1]:
              if db == 'UP':
                  name = uniprot_client.get_mnemonic(db_id)
              else:
                  name = ''
              row = [text_string, db, db_id, count, name]
              rows.append(row)
  
      write_unicode_csv(filename, rows, delimiter=',', quotechar='"',
                        quoting=csv.QUOTE_MINIMAL, lineterminator='\r\n')
docs: Dump a list of agents along with groundings and counts into a csv file
  
      Parameters
      ----------
      filename : str
          Filepath for output file
      grouped_by_text : list of tuple
          List of tuples of the form output by agent_texts_with_grounding