code: def _collect_recipes(
      tape, argnum, method_map, diagonal_shifts, off_diagonal_shifts
  ):
      r"""Extract second order recipes for the tape operations for the diagonal of the Hessian
      as well as the first-order derivative recipes for the off-diagonal entries.
      """
      diag_argnum = qml.math.diag(argnum)
      offdiag_argnum = qml.math.any(
          argnum ^ qml.math.diag(qml.math.diag(argnum)), axis=0
      )
  
      diag_recipes = []
      partial_offdiag_recipes = []
      diag_shifts_idx = offdiag_shifts_idx = 0
      for i, (d, od) in enumerate(zip(diag_argnum, offdiag_argnum)):
          if not d or method_map[i] == "0":
              # hessian will be set to 0 for this row/column
              diag_recipes.append(None)
          else:
              # Get the diagonal second-order derivative recipe
              diag_shifts = (
                  None
                  if diagonal_shifts is None
                  else diagonal_shifts[diag_shifts_idx]
              )
              diag_recipes.append(
                  _get_operation_recipe(tape, i, diag_shifts, order=2)
              )
              diag_shifts_idx += 1
  
          if not od or method_map[i] == "0":
              # hessian will be set to 0 for this row/column
              partial_offdiag_recipes.append((None, None, None))
          else:
              # Create the first-order gradient recipes per parameter for off-diagonal entries
              offdiag_shifts = (
                  None
                  if off_diagonal_shifts is None
                  else off_diagonal_shifts[offdiag_shifts_idx]
              )
              partial_offdiag_recipes.append(
                  _get_operation_recipe(
                      tape, i, offdiag_shifts, order=1
                  )
              )
              offdiag_shifts_idx += 1
  
      return diag_recipes, partial_offdiag_recipes
  
imports: import itertools
  import warnings
  from functools import partial
  from typing import Sequence, Callable
  import numpy
  import pennylane
  from pennylane.measurements import ProbabilityMP, StateMP, VarianceMP
  from pennylane.transforms import transform
  from .general_shift_rules import _combine_shift_rules, generate_multishifted_tapes, generate_shifted_tapes
  from .gradient_transform import find_and_validate_gradient_methods
  from .parameter_shift import _get_operation_recipe
  from .hessian_transform import _process_jacs
label_desc: Use image node_id 2 for calling a global function with example usage: _collect_recipes(tape, argnum, method_map, diagonal_shifts, off_diagonal_shifts) and returns: diag_recipes,  partial_offdiag_recipes