<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _apply_bin_map(self, old_frequencies, new_frequencies, old_errors2, new_errors2, bin_map, axis=0):
 """Fill new data arrays using a map. Parameters old_frequencies : np.ndarray Source of frequencies data new_frequencies : np.ndarray Target of frequencies data old_errors2 : np.ndarray Source of errors data new_errors2 : np.ndarray Target of errors data bin_map: Iterable[(old, new)] or int or None As in _reshape_data axis: int On which axis to apply See also -------- HistogramBase._reshape_data """

        if old_frequencies is not None and old_frequencies.shape[axis] > 0:
            if isinstance(bin_map, int):
                new_index = [slice(None) for i in range(self.ndim)]
                new_index[axis] = slice(bin_map, bin_map + old_frequencies.shape[axis])
                new_frequencies[tuple(new_index)] += old_frequencies
                new_errors2[tuple(new_index)] += old_errors2
            else:
                for (old, new) in bin_map:      # Generic enough
                    new_index = [slice(None) for i in range(self.ndim)]
                    new_index[axis] = new
                    old_index = [slice(None) for i in range(self.ndim)]
                    old_index[axis] = old
                    new_frequencies[tuple(new_index)] += old_frequencies[tuple(old_index)]
                    new_errors2[tuple(new_index)] += old_errors2[tuple(old_index)]