code: def grad_fn(tape, dev, fn=qml.gradients.hadamard_grad, **kwargs):
      """Utility function to automate execution and processing of gradient tapes"""
      tapes, fn = fn(tape, **kwargs)
      return fn(dev.execute(tapes)), tapes
  
imports: import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: grad_fn(tape, dev, fn) and returns: fn,  tapes