<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def avg_inner_product(data1, data2, bin_size):
 """ Calculate the time-domain inner product averaged over bins. Parameters data1: pycbc.types.TimeSeries First data set. data2: pycbc.types.TimeSeries Second data set, with same duration and sample rate as data1. bin_size: float Duration of the bins the data will be divided into to calculate the inner product. Returns ------- inner_prod: list The (complex) inner product of data1 and data2 obtained in each bin. amp: float The absolute value of the median of the inner product. phi: float The angle of the median of the inner product. """

    assert data1.duration == data2.duration
    assert data1.sample_rate == data2.sample_rate
    seglen = int(bin_size * data1.sample_rate)
    inner_prod = []
    for idx in range(int(data1.duration / bin_size)):
        start, end = idx * seglen, (idx+1) * seglen
        norm = len(data1[start:end])
        bin_prod = 2 * sum(data1.data[start:end].real *
                           numpy.conjugate(data2.data[start:end])) / norm
        inner_prod.append(bin_prod)

    # Get the median over all bins to avoid outliers due to the presence
    # of a signal in a particular bin.
    inner_median = complex_median(inner_prod)
    return inner_prod, numpy.abs(inner_median), numpy.angle(inner_median)