class_docstr: An arbitrary Hermitian observable.
  
  For a Hermitian matrix :math:`A`, the expectation command returns the value
  
  .. math::
      \braket{A} = \braketT{\psi}{\cdots \otimes I\otimes A\otimes I\cdots}{\psi}
  
  where :math:`A` acts on the requested wires.
  
  If acting on :math:`N` wires, then the matrix :math:`A` must be of size
  :math:`2^N\times 2^N`.
  
  **Details:**
  
  * Number of wires: Any
  * Number of parameters: 1
  * Gradient recipe: None
  
  Args:
      A (array or Sequence): square hermitian matrix
      wires (Sequence[int] or int): the wire(s) the operation acts on
      id (str or None): String representing the operation (optional)
class_docstr_tok: ["An","arbitrary","Hermitian","observable",".","For","a","Hermitian","matrix",":","math",":","`","A","`",",","the","expectation","command","returns","the","value","..","math",":",":","\\braket","{","A","}","=","\\braketT","{","\\psi","}","{","\\cdots","\\otimes","I\\otimes","A\\otimes","I\\cdots","}","{","\\psi","}","where",":","math",":","`","A","`","acts","on","the","requested","wires",".","If","acting","on",":","math",":","`","N","`","wires",",","then","the","matrix",":","math",":","`","A","`","must","be","of","size",":","math",":","`","2^N\\times","2^N","`",".","*","*","Details",":","*","*","*","Number","of","wires",":","Any","*","Number","of","parameters",":","1","*","Gradient","recipe",":","None","Args",":","A","(","array","or","Sequence",")",":","square","hermitian","matrix","wires","(","Sequence","[","int","]","or","int",")",":","the","wire","(","s",")","the","operation","acts","on","id","(","str","or","None",")",":","String","representing","the","operation","(","optional",")"]
docstr: Validate the input matrix.
docstr_tok: ["Validate","the","input","matrix","."]
code: def _validate_input(A, expected_mx_shape=None):
      """Validate the input matrix."""
      if len(A.shape) != 2 or A.shape[0] != A.shape[1]:
          raise ValueError("Observable must be a square matrix.")
  
      if (
          expected_mx_shape is not None
          and A.shape[0] != expected_mx_shape
      ):
          raise ValueError(
              f"Expected input matrix to have shape {expected_mx_shape}x{expected_mx_shape}, but "
              f"a matrix with shape {A.shape[0]}x{A.shape[0]} was passed."
          )
  
      if not qml.math.allclose(A, qml.math.T(qml.math.conj(A))):
          raise ValueError("Observable must be Hermitian.")
  
imports: from copy import copy
  from collections.abc import Sequence
  import numpy
  from scipy.sparse import csr_matrix
  import pennylane
  from pennylane.operation import AnyWires, Observable, Operation
  from pennylane.wires import Wires
  from .matrix_ops import QubitUnitary
label_desc: Use image node_id 2 for calling the Hermitian obj's underlying member method code with example usage: obj._validate_input(A, expected_mx_shape) without return types