def METHOD_NAME(cls, operator):
    try:
        from qiskit.providers.aer.library import SaveExpectationValue
    except ImportError as ex:
        raise MissingOptionalLibraryError(
            libname="qiskit-aer",
            name="AerPauliExpectation",
            pip_install="pip install qiskit-aer",
        ) from ex
    # The 'expval_measurement' label on the save instruction is special - the
    # CircuitSampler will look for it to know that the circuit is a Expectation
    # measurement, and not simply a
    # circuit to replace with a DictStateFn
    if operator.__class__ == ListOp:
        return operator.traverse(cls.METHOD_NAME)
    if isinstance(operator, PauliSumOp):
        save_instruction = SaveExpectationValue(operator.primitive, "expval_measurement")
        return CircuitStateFn(
            save_instruction, coeff=operator.coeff, is_measurement=True, from_operator=True
        )
    # Change to Pauli representation if necessary
    if {"Pauli"} != operator.primitive_strings():
        logger.warning(
            "Measured Observable is not composed of only Paulis, converting to "
            "Pauli representation, which can be expensive."
        )
        # Setting massive=False because this conversion is implicit. User can perform this
        # action on the Observable with massive=True explicitly if they so choose.
        operator = operator.to_pauli_op(massive=False)
    if isinstance(operator, SummedOp):
        sparse_pauli = reduce(
            add, (meas.coeff * SparsePauliOp(meas.primitive) for meas in operator.oplist)
        )
        save_instruction = SaveExpectationValue(sparse_pauli, "expval_measurement")
        return CircuitStateFn(
            save_instruction, coeff=operator.coeff, is_measurement=True, from_operator=True
        )
    if isinstance(operator, PauliOp):
        sparse_pauli = operator.coeff * SparsePauliOp(operator.primitive)
        save_instruction = SaveExpectationValue(sparse_pauli, "expval_measurement")
        return CircuitStateFn(save_instruction, is_measurement=True, from_operator=True)
    raise TypeError(
        f"Conversion of OperatorStateFn of {operator.__class__.__name__} is not defined."
    )