def assign_weights(weights, network):
    """Assign the given parameters to the TensorLayer network.

    Parameters
    ----------
    weights : list of array
        A list of model weights (array) in order.
    network : :class:`Layer`
        The network to be assigned.

    Returns
    --------
    1) list of operations if in graph mode
            A list of tf ops in order that assign weights. Support sess.run(ops) manually.
    2) list of tf variables if in eager mode
            A list of tf variables (assigned weights) in order.

    Examples
    --------

    References
    ----------
    - `Assign value to a TensorFlow variable <http://stackoverflow.com/questions/34220532/how-to-assign-value-to-a-tensorflow-variable>`__

    """
    ops = []
    for idx, param in enumerate(weights):
        ops.append(network.all_weights[idx].assign(param))
    return ops
