<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def align_traces(trace_list, shift_len, master=False, positive=False, plot=False):
 """ Align traces relative to each other based on their cross-correlation value. Uses the :func:`eqcorrscan.core.match_filter.normxcorr2` function to find the optimum shift to align traces relative to a master event. Either uses a given master to align traces, or uses the trace with the highest MAD amplitude. :type trace_list: list :param trace_list: List of traces to align :type shift_len: int :param shift_len: Length to allow shifting within in samples :type master: obspy.core.trace.Trace :param master: Master trace to align to, if set to False will align to \ the largest amplitude trace (default) :type positive: bool :param positive: Return the maximum positive cross-correlation, or the \ absolute maximum, defaults to False (absolute maximum). :type plot: bool :param plot: If true, will plot each trace aligned with the master. :returns: list of shifts and correlations for best alignment in seconds. :rtype: list """

    from eqcorrscan.core.match_filter import normxcorr2
    from eqcorrscan.utils.plotting import xcorr_plot
    traces = deepcopy(trace_list)
    if not master:
        # Use trace with largest MAD amplitude as master
        master = traces[0]
        MAD_master = np.median(np.abs(master.data))
        for i in range(1, len(traces)):
            if np.median(np.abs(traces[i].data)) > MAD_master:
                master = traces[i]
                MAD_master = np.median(np.abs(master.data))
    else:
        print('Using master given by user')
    shifts = []
    ccs = []
    for i in range(len(traces)):
        if not master.stats.sampling_rate == traces[i].stats.sampling_rate:
            raise ValueError('Sampling rates not the same')
        cc_vec = normxcorr2(template=traces[i].data.
                            astype(np.float32)[shift_len:-shift_len],
                            image=master.data.astype(np.float32))
        cc_vec = cc_vec[0]
        shift = np.abs(cc_vec).argmax()
        cc = cc_vec[shift]
        if plot:
            xcorr_plot(template=traces[i].data.
                       astype(np.float32)[shift_len:-shift_len],
                       image=master.data.astype(np.float32), shift=shift,
                       cc=cc)
        shift -= shift_len
        if cc < 0 and positive:
            cc = cc_vec.max()
            shift = cc_vec.argmax() - shift_len
        shifts.append(shift / master.stats.sampling_rate)
        ccs.append(cc)
    return shifts, ccs