def parse_arguments(args):
    """Helper function that parses the given arguments."""
    parser = argparse.ArgumentParser('Direct fidelity estimation.')

    # TODO: Offer some guidance on how to set this flag. Maybe have an
    # option to do an exhaustive sample and do numerical studies to know which
    # choice is the best.
    # Github issue: https://github.com/quantumlib/Cirq/issues/2802
    parser.add_argument(
        '--n_measured_operators',
        default=10,
        type=int,
        help='Numbers of measured operators (Pauli strings). '
        'If the circuit is Clifford, these operators are '
        'computed by sampling for the basis of stabilizers. If '
        'the circuit is not Clifford, this is a random sample '
        'all the possible operators. If the value of this '
        'parameter is None, we enumerate all the operators '
        'which is 2**n_qubit for Clifford circuits and '
        '4**n_qubits otherwise.',
    )

    parser.add_argument(
        '--samples_per_term',
        default=0,
        type=int,
        help='Number of samples per trial or 0 if no sampling.',
    )

    return vars(parser.parse_args(args))
Helper function that parses the given arguments.
examples/direct_fidelity_estimation.py