code: def test_custom_operator_with_matrix():
      """Test that apply_operation works with any operation that defines a matrix."""
  
      mat = np.array(
          [
              [0.39918205 + 0.3024376j, -0.86421077 + 0.04821758j],
              [0.73240679 + 0.46126509j, 0.49576832 - 0.07091251j],
          ]
      )
  
      # pylint: disable=too-few-public-methods
      class CustomOp(Operation):
          num_wires = 1
  
          def matrix(self):
              return mat
  
      state = np.array(
          [-0.30688912 - 0.4768824j, 0.8100052 - 0.14931113j]
      )
  
      new_state = apply_operation(CustomOp(0), state)
      assert qml.math.allclose(new_state, mat @ state)
  
imports: from functools import reduce
  import pytest
  import numpy
  from scipy.stats import unitary_group
  import pennylane
  from pennylane.operation import _UNSET_BATCH_SIZE, Operation
  from pennylane.devices.qubit.apply_operation import apply_operation, apply_operation_einsum, apply_operation_tensordot
label_desc: Use image node_id 1 for calling a global function with example usage: test_custom_operator_with_matrix() and returns: mat