class_docstr: The MERA template broadcasts an input circuit across many wires following the
  architecture of a multi-scale entanglement renormalization ansatz tensor network.
  This architecture can be found in `arXiv:quant-ph/0610099 <https://arxiv.org/abs/quant-ph/0610099>`_
  and closely resembles `quantum convolutional neural networks <https://arxiv.org/abs/1810.03787>`_.
  
  The argument ``block`` is a user-defined quantum circuit. Each ``block`` may depend on a different set of parameters.
  These are passed as a list by the ``template_weights`` argument.
  
  For more details, see *Usage Details* below.
  
  Args:
      wires (Iterable): wires that the template acts on
      n_block_wires (int): number of wires per block
      block (Callable): quantum circuit that defines a block
      n_params_block (int): the number of parameters in a block
      template_weights (Sequence): list containing the weights for all blocks
  
  .. details::
      :title: Usage Details
  
      In general, the block takes D parameters and **must** have the following signature:
  
      .. code-block:: python
  
          unitary(parameter1, parameter2, ... parameterD, wires)
  
      For a block with multiple parameters, ``n_params_block`` is equal to the number of parameters in ``block``.
      For a block with a single parameter, ``n_params_block`` is equal to the length of the parameter array.
  
      To avoid using ragged arrays, all block parameters should have the same dimension.
  
      The length of the ``template_weights`` argument should match the number of blocks.
      The expected number of blocks can be obtained from ``qml.MERA.get_n_blocks(wires, n_block_wires)``.
  
      This example demonstrates the use of ``MERA`` for a simple block.
  
      .. code-block:: python
  
          import pennylane as qml
          import numpy as np
  
          def block(weights, wires):
              qml.CNOT(wires=[wires[0],wires[1]])
              qml.RY(weights[0], wires=wires[0])
              qml.RY(weights[1], wires=wires[1])
  
          n_wires = 4
          n_block_wires = 2
          n_params_block = 2
          n_blocks = qml.MERA.get_n_blocks(range(n_wires),n_block_wires)
          template_weights = [[0.1,-0.3]]*n_blocks
  
          dev= qml.device('default.qubit',wires=range(n_wires))
          @qml.qnode(dev)
          def circuit(template_weights):
              qml.MERA(range(n_wires),n_block_wires,block, n_params_block, template_weights)
              return qml.expval(qml.PauliZ(wires=1))
  
      It may be necessary to reorder the wires to see the MERA architecture clearly:
  
      >>> print(qml.draw(circuit, expansion_strategy='device', wire_order=[2,0,1,3])(template_weights))
      2: ───────────────╭●──RY(0.10)──╭X──RY(-0.30)───────────────┤
      0: ─╭X──RY(-0.30)─│─────────────╰●──RY(0.10)──╭●──RY(0.10)──┤
      1: ─╰●──RY(0.10)──│─────────────╭X──RY(-0.30)─╰X──RY(-0.30)─┤  <Z>
      3: ───────────────╰X──RY(-0.30)─╰●──RY(0.10)────────────────┤
class_docstr_tok: ["The","MERA","template","broadcasts","an","input","circuit","across","many","wires","following","the","architecture","of","a","multi-scale","entanglement","renormalization","ansatz","tensor","network",".","This","architecture","can","be","found","in","`","arXiv",":","quant-ph\/0610099","<","https",":","\/\/arxiv.org\/abs\/quant-ph\/0610099",">","`","_","and","closely","resembles","`","quantum","convolutional","neural","networks","<","https",":","\/\/arxiv.org\/abs\/1810.03787",">","`","_",".","The","argument","``","block","``","is","a","user-defined","quantum","circuit",".","Each","``","block","``","may","depend","on","a","different","set","of","parameters",".","These","are","passed","as","a","list","by","the","``","template_weights","``","argument",".","For","more","details",",","see","*","Usage","Details","*","below",".","Args",":","wires","(","Iterable",")",":","wires","that","the","template","acts","on","n_block_wires","(","int",")",":","number","of","wires","per","block","block","(","Callable",")",":","quantum","circuit","that","defines","a","block","n_params_block","(","int",")",":","the","number","of","parameters","in","a","block","template_weights","(","Sequence",")",":","list","containing","the","weights","for","all","blocks","..","details",":",":",":","title",":","Usage","Details","In","general",",","the","block","takes","D","parameters","and","*","*","must","*","*","have","the","following","signature",":","..","code-block",":",":","python","unitary","(","parameter1",",","parameter2",",","...","parameterD",",","wires",")","For","a","block","with","multiple","parameters",",","``","n_params_block","``","is","equal","to","the","number","of","parameters","in","``","block","``",".","For","a","block","with","a","single","parameter",",","``","n_params_block","``","is","equal","to","the","length","of","the","parameter","array",".","To","avoid","using","ragged","arrays",",","all","block","parameters","should","have","the","same","dimension",".","The","length","of","the","``","template_weights","``","argument","should","match","the","number","of","blocks",".","The","expected","number","of","blocks","can","be","obtained","from","``","qml.MERA.get_n_blocks","(","wires",",","n_block_wires",")","``",".","This","example","demonstrates","the","use","of","``","MERA","``","for","a","simple","block",".","..","code-block",":",":","python","import","pennylane","as","qml","import","numpy","as","np","def","block","(","weights",",","wires",")",":","qml.CNOT","(","wires=","[","wires","[","0","]",",","wires","[","1","]","]",")","qml.RY","(","weights","[","0","]",",","wires=wires","[","0","]",")","qml.RY","(","weights","[","1","]",",","wires=wires","[","1","]",")","n_wires","=","4","n_block_wires","=","2","n_params_block","=","2","n_blocks","=","qml.MERA.get_n_blocks","(","range","(","n_wires",")",",","n_block_wires",")","template_weights","=","[","[","0.1",",","-0.3","]","]","*","n_blocks","dev=","qml.device","(","'default.qubit","'",",","wires=range","(","n_wires",")",")","@","qml.qnode","(","dev",")","def","circuit","(","template_weights",")",":","qml.MERA","(","range","(","n_wires",")",",","n_block_wires",",","block",",","n_params_block",",","template_weights",")","return","qml.expval","(","qml.PauliZ","(","wires=1",")",")","It","may","be","necessary","to","reorder","the","wires","to","see","the","MERA","architecture","clearly",":",">",">",">","print","(","qml.draw","(","circuit",",","expansion_strategy='device","'",",","wire_order=","[","2,0,1,3","]",")","(","template_weights",")",")","2",":","\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256d\u25cf\u2500\u2500RY","(","0.10",")","\u2500\u2500\u256dX\u2500\u2500RY","(","-0.30",")","\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524","0",":","\u2500\u256dX\u2500\u2500RY","(","-0.30",")","\u2500\u2502\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2570\u25cf\u2500\u2500RY","(","0.10",")","\u2500\u2500\u256d\u25cf\u2500\u2500RY","(","0.10",")","\u2500\u2500\u2524","1",":","\u2500\u2570\u25cf\u2500\u2500RY","(","0.10",")","\u2500\u2500\u2502\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256dX\u2500\u2500RY","(","-0.30",")","\u2500\u2570X\u2500\u2500RY","(","-0.30",")","\u2500\u2524","<","Z",">","3",":","\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2570X\u2500\u2500RY","(","-0.30",")","\u2500\u2570\u25cf\u2500\u2500RY","(","0.10",")","\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"]
code: def _unflatten(cls, data, metadata):
      new_op = cls.__new__(cls)
      new_op._hyperparameters = dict(metadata[1])
      Operation.__init__(new_op, data, wires=metadata[0])
      return new_op
  
file_path: pennylane/pennylane/templates/tensornetworks/mera.py
imports: import warnings
  from typing import Callable
  import numpy
  import pennylane
  from pennylane.operation import Operation, AnyWires
label_desc: Use image node_id 2 for calling the MERA obj's underlying member method code with example usage: obj._unflatten(cls, data, metadata) and returns: new_op