<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def select_spikes(cluster_ids=None, max_n_spikes_per_cluster=None, spikes_per_cluster=None, batch_size=None, subset=None, ):
 """Return a selection of spikes belonging to the specified clusters."""

    subset = subset or 'regular'
    assert _is_array_like(cluster_ids)
    if not len(cluster_ids):
        return np.array([], dtype=np.int64)
    if max_n_spikes_per_cluster in (None, 0):
        selection = {c: spikes_per_cluster(c) for c in cluster_ids}
    else:
        assert max_n_spikes_per_cluster > 0
        selection = {}
        n_clusters = len(cluster_ids)
        for cluster in cluster_ids:
            # Decrease the number of spikes per cluster when there
            # are more clusters.
            n = int(max_n_spikes_per_cluster * exp(-.1 * (n_clusters - 1)))
            n = max(1, n)
            spike_ids = spikes_per_cluster(cluster)
            if subset == 'regular':
                # Regular subselection.
                if batch_size is None or len(spike_ids) <= max(batch_size, n):
                    spike_ids = regular_subset(spike_ids, n_spikes_max=n)
                else:
                    # Batch selections of spikes.
                    spike_ids = get_excerpts(spike_ids,
                                             n // batch_size,
                                             batch_size)
            elif subset == 'random' and len(spike_ids) > n:
                # Random subselection.
                spike_ids = np.random.choice(spike_ids, n, replace=False)
                spike_ids = np.unique(spike_ids)
            selection[cluster] = spike_ids
    return _flatten_per_cluster(selection)