<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def print_map(map_source, x, y, zoom=14, width=297, height=210, dpi=300, format="pdf"):
 """ Download map tiles and stitch them together in a single image, ready for printing. Args: map_source (MapSource):
 Map to download x (float):
 map center x-coordinate in Mercator projection (EPSG:4326) y (float):
 map center y-coordinate in Mercator projection (EPSG:4326) zoom (int):
 tile zoom level to use for printing width (float):
 page width in mm height (float):
 page height in mm dpi (int):
 resolution in dots per inch format (str):
 output format. Anything supported by ``Pillow.Image.save``. E.g. "pdf", "jpeg", "png". Returns: str: path of temporary output file. """

    bbox = get_print_bbox(x, y, zoom, width, height, dpi)
    tiles = [
        get_tiles(tile_layer, bbox) for tile_layer in map_source.layers if
        tile_layer.min_zoom <= zoom <= tile_layer.max_zoom
        ]
    img = stitch_map(tiles, width, height, bbox, dpi)
    outfile = NamedTemporaryFile(delete=False)
    img.save(outfile, format, quality=100, dpi=(dpi, dpi))
    outfile.close()
    return outfile.name