def validate_entangler_map(entangler_map, num_qubits, allow_double_entanglement=False):
    """Validate a user supplied entangler map and converts entries to ints.

    Args:
        entangler_map (list[list]) : An entangler map, keys are source qubit index (int),
                                value is array
                                of target qubit index(es) (int)
        num_qubits (int) : Number of qubits
        allow_double_entanglement (bool): If we allow in two qubits can be entangled each other

    Returns:
        list: Validated/converted map

    Raises:
        TypeError: entangler map is not list type or list of list
        ValueError: the index of entangler map is out of range
        ValueError: the qubits are cross-entangled.

    """

    if isinstance(entangler_map, dict):
        raise TypeError("The type of entangler map is changed to list of list.")

    if not isinstance(entangler_map, list):
        raise TypeError("Entangler map type 'list' expected")

    for src_to_targ in entangler_map:
        if not isinstance(src_to_targ, list):
            raise TypeError('Entangle index list expected but got {}'.format(type(src_to_targ)))

    ret_map = []
    ret_map = [[int(src), int(targ)] for src, targ in entangler_map]

    for src, targ in ret_map:
        if src < 0 or src >= num_qubits:
            raise ValueError(
                'Qubit entangle source value {} invalid for {} qubits'.format(src, num_qubits))
        if targ < 0 or targ >= num_qubits:
            raise ValueError(
                'Qubit entangle target value {} invalid for {} qubits'.format(targ, num_qubits))
        if not allow_double_entanglement and [targ, src] in ret_map:
            raise ValueError('Qubit {} and {} cross-entangled.'.format(src, targ))

    return ret_map