code: def compute_indices(wires, n_block_wires):
      """Generate a list containing the wires for each block.
  
      Args:
          wires (Iterable): wires that the template acts on
          n_block_wires (int): number of wires per block
  
      Returns:
          layers (tuple): array of wire labels for each block
      """
  
      n_wires = len(wires)
  
      if n_block_wires % 2 != 0:
          raise ValueError(
              f"n_block_wires must be an even integer; got {n_block_wires}"
          )
  
      if n_block_wires < 2:
          raise ValueError(
              f"number of wires in each block must be larger than or equal to 2; got n_block_wires = {n_block_wires}"
          )
  
      if n_block_wires > n_wires:
          raise ValueError(
              f"n_block_wires must be smaller than or equal to the number of wires; "
              f"got n_block_wires = {n_block_wires} and number of wires = {n_wires}"
          )
  
      if not np.log2(
          n_wires / n_block_wires
      ).is_integer():  # pylint:disable=no-member
          warnings.warn(
              f"The number of wires should be n_block_wires times 2^n; got n_wires/n_block_wires = {n_wires/n_block_wires}"
          )
  
      n_wires = (
          2 ** (int(np.log2(len(wires) / n_block_wires)))
          * n_block_wires
      )
      n_layers = int(np.log2(n_wires // n_block_wires)) + 1
  
      half_block_wires = n_block_wires // 2
  
      block_wires = []
      for layer in range(n_layers):
          lower_shift = (2 ** (layer) - 1) * half_block_wires
          upper_shift = (2 ** (layer + 1) - 1) * half_block_wires
  
          step = 2**layer * n_block_wires
          for block_offset in range(
              0, n_wires - half_block_wires, step
          ):
              wires1 = tuple(
                  wires[block_offset + lower_shift + i]
                  for i in range(half_block_wires)
              )
              wires2 = tuple(
                  wires[block_offset + upper_shift + i]
                  for i in range(half_block_wires)
              )
              block_wires.append(wires1 + wires2)
  
      return tuple(block_wires)
  
file_path: pennylane/pennylane/templates/tensornetworks/ttn.py
imports: import warnings
  import numpy
  import pennylane
  from pennylane.operation import Operation, AnyWires
label_desc: Use image node_id 1 for calling a global function with example usage: compute_indices(wires, n_block_wires) and returns: tuple