code: def _check_tape_validity(tape: QuantumTape):
      """Helper function to check that the tape is valid."""
      cv_types = (qml.operation.CVOperation, qml.operation.CVObservable)
      ops_cv = any(
          isinstance(op, cv_types) and op.name != "Identity"
          for op in tape.operations
      )
      obs_cv = any(
          isinstance(getattr(op, "obs", None), cv_types)
          and not isinstance(getattr(op, "obs", None), qml.Identity)
          for op in tape.measurements
      )
      if ops_cv or obs_cv:
          raise ValueError(
              "Continuous variable operations and observables are not supported."
          )
  
      for mp in tape.measurements:
          if isinstance(
              mp, (CountsMP, ProbabilityMP, SampleMP)
          ) and not (mp.obs or mp._wires or mp.mv):
              raise ValueError(
                  f"Cannot use {mp.__class__.__name__} as a measurement without specifying wires "
                  "when using qml.defer_measurements. Deferred measurements can occur "
                  "automatically when using mid-circuit measurements on a device that does not "
                  "support them."
              )
  
          if mp.__class__.__name__ == "StateMP":
              raise ValueError(
                  "Cannot use StateMP as a measurement when using qml.defer_measurements. "
                  "Deferred measurements can occur automatically when using mid-circuit "
                  "measurements on a device that does not support them."
              )
  
file_path: pennylane/pennylane/transforms/defer_measurements.py
imports: from typing import Sequence, Callable
  import pennylane
  from pennylane.measurements import MidMeasureMP, ProbabilityMP, SampleMP, CountsMP, MeasurementValue
  from pennylane.ops.op_math import ctrl
  from pennylane.tape import QuantumTape
  from pennylane.transforms import transform
  from pennylane.wires import Wires
  from pennylane.queuing import QueuingManager
label_desc: Use image node_id 1 for calling a global function with example usage: _check_tape_validity(tape) without return types