class_docstr: Apply two-local gate operations using a canonical 2-complete linear (2-CCL) swap network.
  
  Args:
      wires (Iterable or Wires): ordered sequence of wires on which the swap network acts
      acquaintances (Callable): callable `func(index, wires, param=None, **kwargs)` that returns
          a two-local operation applied on a pair of logical wires specified by `index` currently
          stored in physical wires provided by `wires` before they are swapped apart.
          Parameters for the operation are specified using `param`, and any additional
          keyword arguments for the callable should be provided using the ``kwargs`` separately
      weights (tensor): weight tensor for the parameterized acquaintances of length
          :math:`N \times (N - 1) / 2`, where `N` is the length of `wires`
      fermionic (bool): If ``True``, qubits are realized as fermionic modes and :class:`~.pennylane.FermionicSWAP` with :math:`\phi=\pi` is used instead of :class:`~.pennylane.SWAP`
      shift (bool): If ``True``, odd-numbered layers begins from the second qubit instead of first one
      **kwargs: additional keyword arguments for `acquaintances`
  
  Raises:
      ValueError: if inputs do not have the correct format
  
  **Example**
  
  .. code-block:: python
  
      >>> import pennylane as qml
      >>> dev = qml.device('default.qubit', wires=5)
      >>> acquaintances = lambda index, wires, param=None: qml.CNOT(index)
      >>> @qml.qnode(dev)
      ... def swap_network_circuit():
      ...    qml.templates.TwoLocalSwapNetwork(dev.wires, acquaintances, fermionic=True, shift=False)
      ...    return qml.state()
      >>> qml.draw(swap_network_circuit, expansion_strategy='device')()
      0: ─╭●─╭fSWAP(3.14)─────────────────╭●─╭fSWAP(3.14)─────────────────╭●─╭fSWAP(3.14)─┤  State
      1: ─╰X─╰fSWAP(3.14)─╭●─╭fSWAP(3.14)─╰X─╰fSWAP(3.14)─╭●─╭fSWAP(3.14)─╰X─╰fSWAP(3.14)─┤  State
      2: ─╭●─╭fSWAP(3.14)─╰X─╰fSWAP(3.14)─╭●─╭fSWAP(3.14)─╰X─╰fSWAP(3.14)─╭●─╭fSWAP(3.14)─┤  State
      3: ─╰X─╰fSWAP(3.14)─╭●─╭fSWAP(3.14)─╰X─╰fSWAP(3.14)─╭●─╭fSWAP(3.14)─╰X─╰fSWAP(3.14)─┤  State
      4: ─────────────────╰X─╰fSWAP(3.14)─────────────────╰X─╰fSWAP(3.14)─────────────────┤  State
  
  .. details::
      :title: Usage Details
  
      More complex acquaintances can be utilized with the template. For example:
  
      .. code-block:: python
  
          >>> dev = qml.device('default.qubit', wires=5)
          >>> weights = np.random.random(size=qml.TwoLocalSwapNetwork.shape(len(dev.wires)))
          >>> print(weights)
          tensor([0.20308242, 0.91906199, 0.67988804, 0.81290256, 0.08708985,
                  0.81860084, 0.34448344, 0.05655892, 0.61781612, 0.51829044], requires_grad=True)
          >>> acquaintances = lambda index, wires, param: (qml.CRY(param, wires=index)
          ...                                  if np.abs(wires[0]-wires[1]) else qml.CRZ(param, wires=index))
          >>> @qml.qnode(dev)
          ... def swap_network_circuit():
          ...    qml.templates.TwoLocalSwapNetwork(dev.wires, acquaintances, weights, fermionic=False)
          ...    return qml.state()
          >>> qml.draw(swap_network_circuit, expansion_strategy='device')()
          0: ─╭●────────╭SWAP─────────────────╭●────────╭SWAP─────────────────╭●────────╭SWAP─┤  State
          1: ─╰RY(0.20)─╰SWAP─╭●────────╭SWAP─╰RY(0.09)─╰SWAP─╭●────────╭SWAP─╰RY(0.62)─╰SWAP─┤  State
          2: ─╭●────────╭SWAP─╰RY(0.68)─╰SWAP─╭●────────╭SWAP─╰RY(0.34)─╰SWAP─╭●────────╭SWAP─┤  State
          3: ─╰RY(0.92)─╰SWAP─╭●────────╭SWAP─╰RY(0.82)─╰SWAP─╭●────────╭SWAP─╰RY(0.52)─╰SWAP─┤  State
          4: ─────────────────╰RY(0.81)─╰SWAP─────────────────╰RY(0.06)─╰SWAP─────────────────┤  State
class_docstr_tok: ["Apply","two-local","gate","operations","using","a","canonical","2-complete","linear","(","2-CCL",")","swap","network",".","Args",":","wires","(","Iterable","or","Wires",")",":","ordered","sequence","of","wires","on","which","the","swap","network","acts","acquaintances","(","Callable",")",":","callable","`","func","(","index",",","wires",",","param=None",",","*","*","kwargs",")","`","that","returns","a","two-local","operation","applied","on","a","pair","of","logical","wires","specified","by","`","index","`","currently","stored","in","physical","wires","provided","by","`","wires","`","before","they","are","swapped","apart",".","Parameters","for","the","operation","are","specified","using","`","param","`",",","and","any","additional","keyword","arguments","for","the","callable","should","be","provided","using","the","``","kwargs","``","separately","weights","(","tensor",")",":","weight","tensor","for","the","parameterized","acquaintances","of","length",":","math",":","`","N","\\times","(","N","-","1",")","\/","2","`",",","where","`","N","`","is","the","length","of","`","wires","`","fermionic","(","bool",")",":","If","``","True","``",",","qubits","are","realized","as","fermionic","modes","and",":","class",":","`","~.pennylane.FermionicSWAP","`","with",":","math",":","`","\\phi=\\pi","`","is","used","instead","of",":","class",":","`","~.pennylane.SWAP","`","shift","(","bool",")",":","If","``","True","``",",","odd-numbered","layers","begins","from","the","second","qubit","instead","of","first","one","*","*","kwargs",":","additional","keyword","arguments","for","`","acquaintances","`","Raises",":","ValueError",":","if","inputs","do","not","have","the","correct","format","*","*","Example","*","*","..","code-block",":",":","python",">",">",">","import","pennylane","as","qml",">",">",">","dev","=","qml.device","(","'default.qubit","'",",","wires=5",")",">",">",">","acquaintances","=","lambda","index",",","wires",",","param=None",":","qml.CNOT","(","index",")",">",">",">","@","qml.qnode","(","dev",")","...","def","swap_network_circuit","(",")",":","...","qml.templates.TwoLocalSwapNetwork","(","dev.wires",",","acquaintances",",","fermionic=True",",","shift=False",")","...","return","qml.state","(",")",">",">",">","qml.draw","(","swap_network_circuit",",","expansion_strategy='device","'",")","(",")","0",":","\u2500\u256d\u25cf\u2500\u256dfSWAP","(","3.14",")","\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256d\u25cf\u2500\u256dfSWAP","(","3.14",")","\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256d\u25cf\u2500\u256dfSWAP","(","3.14",")","\u2500\u2524","State","1",":","\u2500\u2570X\u2500\u2570fSWAP","(","3.14",")","\u2500\u256d\u25cf\u2500\u256dfSWAP","(","3.14",")","\u2500\u2570X\u2500\u2570fSWAP","(","3.14",")","\u2500\u256d\u25cf\u2500\u256dfSWAP","(","3.14",")","\u2500\u2570X\u2500\u2570fSWAP","(","3.14",")","\u2500\u2524","State","2",":","\u2500\u256d\u25cf\u2500\u256dfSWAP","(","3.14",")","\u2500\u2570X\u2500\u2570fSWAP","(","3.14",")","\u2500\u256d\u25cf\u2500\u256dfSWAP","(","3.14",")","\u2500\u2570X\u2500\u2570fSWAP","(","3.14",")","\u2500\u256d\u25cf\u2500\u256dfSWAP","(","3.14",")","\u2500\u2524","State","3",":","\u2500\u2570X\u2500\u2570fSWAP","(","3.14",")","\u2500\u256d\u25cf\u2500\u256dfSWAP","(","3.14",")","\u2500\u2570X\u2500\u2570fSWAP","(","3.14",")","\u2500\u256d\u25cf\u2500\u256dfSWAP","(","3.14",")","\u2500\u2570X\u2500\u2570fSWAP","(","3.14",")","\u2500\u2524","State","4",":","\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2570X\u2500\u2570fSWAP","(","3.14",")","\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2570X\u2500\u2570fSWAP","(","3.14",")","\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524","State","..","details",":",":",":","title",":","Usage","Details","More","complex","acquaintances","can","be","utilized","with","the","template",".","For","example",":","..","code-block",":",":","python",">",">",">","dev","=","qml.device","(","'default.qubit","'",",","wires=5",")",">",">",">","weights","=","np.random.random","(","size=qml.TwoLocalSwapNetwork.shape","(","len","(","dev.wires",")",")",")",">",">",">","print","(","weights",")","tensor","(","[","0.20308242",",","0.91906199",",","0.67988804",",","0.81290256",",","0.08708985",",","0.81860084",",","0.34448344",",","0.05655892",",","0.61781612",",","0.51829044","]",",","requires_grad=True",")",">",">",">","acquaintances","=","lambda","index",",","wires",",","param",":","(","qml.CRY","(","param",",","wires=index",")","...","if","np.abs","(","wires","[","0","]","-wires","[","1","]",")","else","qml.CRZ","(","param",",","wires=index",")",")",">",">",">","@","qml.qnode","(","dev",")","...","def","swap_network_circuit","(",")",":","...","qml.templates.TwoLocalSwapNetwork","(","dev.wires",",","acquaintances",",","weights",",","fermionic=False",")","...","return","qml.state","(",")",">",">",">","qml.draw","(","swap_network_circuit",",","expansion_strategy='device","'",")","(",")","0",":","\u2500\u256d\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256dSWAP\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256d\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256dSWAP\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256d\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256dSWAP\u2500\u2524","State","1",":","\u2500\u2570RY","(","0.20",")","\u2500\u2570SWAP\u2500\u256d\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256dSWAP\u2500\u2570RY","(","0.09",")","\u2500\u2570SWAP\u2500\u256d\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256dSWAP\u2500\u2570RY","(","0.62",")","\u2500\u2570SWAP\u2500\u2524","State","2",":","\u2500\u256d\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256dSWAP\u2500\u2570RY","(","0.68",")","\u2500\u2570SWAP\u2500\u256d\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256dSWAP\u2500\u2570RY","(","0.34",")","\u2500\u2570SWAP\u2500\u256d\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256dSWAP\u2500\u2524","State","3",":","\u2500\u2570RY","(","0.92",")","\u2500\u2570SWAP\u2500\u256d\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256dSWAP\u2500\u2570RY","(","0.82",")","\u2500\u2570SWAP\u2500\u256d\u25cf\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256dSWAP\u2500\u2570RY","(","0.52",")","\u2500\u2570SWAP\u2500\u2524","State","4",":","\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2570RY","(","0.81",")","\u2500\u2570SWAP\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2570RY","(","0.06",")","\u2500\u2570SWAP\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524","State"]
code: def _unflatten(cls, data, metadata):
      new_op = cls.__new__(cls)
      new_op._hyperparameters = dict(
          metadata[1]
      )  # pylint: disable=protected-access
      new_op._weights = data[0]  # pylint: disable=protected-access
      Operation.__init__(new_op, *data, wires=metadata[0])
      return new_op
  
file_path: pennylane/pennylane/templates/swapnetworks/ccl2.py
imports: import warnings
  import numpy
  import pennylane
  from pennylane.operation import Operation, AnyWires
  from pennylane.ops import SWAP, FermionicSWAP
label_desc: Use image node_id 1 for calling the TwoLocalSwapNetwork obj's underlying member method code with example usage: obj._unflatten(cls, data, metadata) and returns: new_op