code: def _get_first_term_tapes(
      layer_i, layer_j, allow_nonunitary, aux_wire
  ):
      r"""Obtain the tapes for the first term of all tensor entries
      belonging to an off-diagonal block.
  
      Args:
          layer_i (list): The first layer of parametrized ops, of the format of
              the layers generated by ``iterate_parametrized_layers``
          layer_j (list): The second layer of parametrized ops
          allow_nonunitary (bool): Whether non-unitary operations are allowed
              in the circuit; passed to ``_get_gen_op``
          aux_wire (object or pennylane.wires.Wires): Auxiliary wire on which to
              control the controlled-generator operations
  
      Returns:
          list[pennylane.tape.QuantumTape]: Transformed tapes that compute the
              first term of the metric tensor for the off-diagonal block belonging
              to the input layers
          list[tuple[int]]: 2-tuple indices assigning the tapes to metric tensor
              entries
      """
  
      tapes = []
      ids = []
      # Exclude the backwards cone of layer_i from the backwards cone of layer_j
      ops_between_cgens = [
          op1
          for op1 in layer_j.pre_ops
          if not any(op1 is op2 for op2 in layer_i.pre_ops)
      ]
  
      # Iterate over differentiated operation in first layer
      for diffed_op_i, par_idx_i in zip(
          layer_i.ops, layer_i.param_inds
      ):
          gen_op_i = _get_gen_op(
              WrappedObj(diffed_op_i), allow_nonunitary, aux_wire
          )
  
          # Iterate over differentiated operation in second layer
          # There will be one tape per pair of differentiated operations
          for diffed_op_j, par_idx_j in zip(
              layer_j.ops, layer_j.param_inds
          ):
              gen_op_j = _get_gen_op(
                  WrappedObj(diffed_op_j), allow_nonunitary, aux_wire
              )
  
              with qml.queuing.AnnotatedQueue() as q:
                  # Initialize auxiliary wire
                  qml.Hadamard(wires=aux_wire)
                  # Apply backward cone of first layer
                  for op in layer_i.pre_ops:
                      qml.apply(op)
                  # Controlled-generator operation of first diff'ed op
                  qml.apply(gen_op_i)
                  # Apply first layer and operations between layers
                  for op in ops_between_cgens:
                      qml.apply(op)
                  # Controlled-generator operation of second diff'ed op
                  qml.apply(gen_op_j)
                  # Measure X on auxiliary wire
                  qml.expval(qml.PauliX(aux_wire))
  
              tapes.append(qml.tape.QuantumScript.from_queue(q))
              # Memorize to which metric entry this tape belongs
              ids.append((par_idx_i, par_idx_j))
  
      return tapes, ids
  
file_path: pennylane/pennylane/gradients/metric_tensor.py
imports: from typing import Sequence, Callable
  import functools
  from functools import partial
  import warnings
  import numpy
  import pennylane
  from pennylane.circuit_graph import LayerData
  from pennylane.queuing import WrappedObj
  from pennylane.transforms import transform
label_desc: Use image node_id 7 for calling a global function with example usage: _get_first_term_tapes(layer_i, layer_j, allow_nonunitary, aux_wire) and returns: tapes,  ids