<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def tilequeue_enqueue_random_pyramids(cfg, peripherals, args):
 """enqueue random pyramids"""


    from tilequeue.stats import RawrTileEnqueueStatsHandler
    from tilequeue.rawr import make_rawr_enqueuer_from_cfg

    logger = make_logger(cfg, 'enqueue_random_pyramids')

    rawr_yaml = cfg.yml.get('rawr')
    assert rawr_yaml, 'Missing rawr yaml'
    group_by_zoom = rawr_yaml.get('group-zoom')
    assert group_by_zoom, 'Missing rawr group-zoom'
    assert isinstance(group_by_zoom, int), 'Invalid rawr group-zoom'

    if args.zoom_start is None:
        zoom_start = group_by_zoom
    else:
        zoom_start = args.zoom_start

    if args.zoom_stop is None:
        zoom_stop = cfg.max_zoom + 1  # +1 because exclusive
    else:
        zoom_stop = args.zoom_stop

    assert zoom_start >= group_by_zoom
    assert zoom_stop > zoom_start

    gridsize = args.gridsize
    total_samples = getattr(args, 'n-samples')
    samples_per_cell = total_samples / (gridsize * gridsize)

    tileset_dim = 2 ** group_by_zoom

    scale_factor = float(tileset_dim) / float(gridsize)

    stats = make_statsd_client_from_cfg(cfg)
    stats_handler = RawrTileEnqueueStatsHandler(stats)
    rawr_enqueuer = make_rawr_enqueuer_from_cfg(
        cfg, logger, stats_handler, peripherals.msg_marshaller)

    for grid_y in xrange(gridsize):
        tile_y_min = int(grid_y * scale_factor)
        tile_y_max = int((grid_y+1) * scale_factor)
        for grid_x in xrange(gridsize):
            tile_x_min = int(grid_x * scale_factor)
            tile_x_max = int((grid_x+1) * scale_factor)

            cell_samples = set()

            for i in xrange(samples_per_cell):

                while True:
                    rand_x = randrange(tile_x_min, tile_x_max)
                    rand_y = randrange(tile_y_min, tile_y_max)
                    sample = rand_x, rand_y
                    if sample in cell_samples:
                        continue
                    cell_samples.add(sample)
                    break

            # enqueue a cell at a time
            # the queue mapper expects to be able to read the entirety of the
            # input into memory first
            for x, y in cell_samples:
                coord = Coordinate(zoom=group_by_zoom, column=x, row=y)
                pyramid = coord_pyramid(coord, zoom_start, zoom_stop)
                rawr_enqueuer(pyramid)