code: def test_custom_operation():
      """Test execution works with a manually defined operator if it has a matrix."""
  
      # pylint: disable=too-few-public-methods
      class MyOperator(qml.operation.Operator):
          num_wires = 1
  
          @staticmethod
          def compute_matrix():
              return qml.PauliX.compute_matrix()
  
      qs = qml.tape.QuantumScript(
          [MyOperator(0)], [qml.expval(qml.PauliZ(0))]
      )
  
      result = simulate(qs)
      assert qml.math.allclose(result, -1.0)
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane.devices.qubit import simulate, get_final_state, measure_final_state
label_desc: Use image node_id 1 for calling a global function with example usage: test_custom_operation() and returns: qml