def sample(
    program: cirq.Circuit,
    *,
    noise: cirq.NOISE_MODEL_LIKE = None,
    param_resolver: cirq.ParamResolver | None = None,
    repetitions: int = 1,
    dtype: type[np.complexfloating] = np.complex64,
    seed: cirq.RANDOM_STATE_OR_SEED_LIKE = None,
) -> cirq.Result:
    """Simulates sampling from the given circuit.

    Args:
        program: The circuit to sample from.
        noise: Noise model to use while running the simulation.
        param_resolver: Parameters to run with the program.
        repetitions: The number of samples to take.
        dtype: The `numpy.dtype` used by the simulation. Typically one of
            `numpy.complex64` or `numpy.complex128`.
            Favors speed over precision by default, i.e. uses `numpy.complex64`.
        seed: The random seed to use for this simulator.

    Returns:
        A `cirq.Result` object containing the requested measurement samples.
    """
    noise_model = devices.NoiseModel.from_noise_model_like(noise)

    # State vector simulation is much faster, but only works if no randomness.
    if noise_model == devices.NO_NOISE:
        if _is_clifford_circuit(program):
            # If all non-measurement operations are clifford, use the Clifford
            # simulator.
            return clifford_simulator.CliffordSimulator(seed=seed).run(
                program, param_resolver=param_resolver, repetitions=repetitions
            )
        if protocols.has_unitary(program):
            return sparse_simulator.Simulator(dtype=dtype, seed=seed).run(
                program=program, param_resolver=param_resolver, repetitions=repetitions
            )

    return density_matrix_simulator.DensityMatrixSimulator(
        dtype=dtype, noise=noise_model, seed=seed
    ).run(program=program, param_resolver=param_resolver, repetitions=repetitions)
Simulates sampling from the given circuit.

    Args:
        program: The circuit to sample from.
        noise: Noise model to use while running the simulation.
        param_resolver: Parameters to run with the program.
        repetitions: The number of samples to take.
        dtype: The `numpy.dtype` used by the simulation. Typically one of
            `numpy.complex64` or `numpy.complex128`.
            Favors speed over precision by default, i.e. uses `numpy.complex64`.
        seed: The random seed to use for this simulator.

    Returns:
        A `cirq.Result` object containing the requested measurement samples.
    
cirq-core/cirq/sim/mux.py