code: def custom_measurement_process(device, spy):
      assert (
          len(spy.call_args_list) > 0
      )  # make sure method is mocked properly
  
      samples = device._samples
      call_args_list = list(spy.call_args_list)
      for call_args in call_args_list:
          meas = call_args.args[1]
          shot_range, bin_size = (
              call_args.kwargs["shot_range"],
              call_args.kwargs["bin_size"],
          )
          if isinstance(meas, (Operator, MeasurementValue)):
              meas = qml.sample(op=meas)
          assert qml.math.allequal(
              device.sample(call_args.args[1], **call_args.kwargs),
              meas.process_samples(
                  samples=samples,
                  wire_order=device.wires,
                  shot_range=shot_range,
                  bin_size=bin_size,
              ),
          )
  
imports: import numpy
  import pytest
  import pennylane
  from pennylane.measurements import MeasurementShapeError, Sample, Shots, MeasurementValue
  from pennylane.operation import Operator
label_desc: Use image node_id 1 for calling a global function with example usage: custom_measurement_process(device, spy) without return types