'Remove the specified formats from the specified books.
:param formats_map: A mapping of book_id to a list of formats to be removed from the book.
:param db_only: If True, only remove the record for the format from the db, do not delete the actual format file from the filesystem.'

@write_api
def remove_formats(self, formats_map, db_only=False):

    table = self.fields[u'formats'].table
    formats_map = {book_id: frozenset(((f or u'').upper() for f in fmts)) for (book_id, fmts) in formats_map.iteritems()}
    for (book_id, fmts) in formats_map.iteritems():
        for fmt in fmts:
            self.format_metadata_cache[book_id].pop(fmt, None)
    if (not db_only):
        removes = defaultdict(set)
        for (book_id, fmts) in formats_map.iteritems():
            try:
                path = self._field_for(u'path', book_id).replace(u'/', os.sep)
            except:
                continue
            for fmt in fmts:
                try:
                    name = self.fields[u'formats'].format_fname(book_id, fmt)
                except:
                    continue
                if (name and path):
                    removes[book_id].add((fmt, name, path))
        if removes:
            self.backend.remove_formats(removes)
    size_map = table.remove_formats(formats_map, self.backend)
    self.fields[u'size'].table.update_sizes(size_map)
    self._update_last_modified(tuple(formats_map.iterkeys()))
