def sweep_to_proto(sweep: cirq.Sweep, repetitions: int = 1) -> params_pb2.ParameterSweep:
    """Converts sweep into an equivalent protobuf representation."""
    product_sweep = None
    if sweep != cirq.UnitSweep:
        sweep = _to_zip_product(sweep)
        product_sweep = params_pb2.ProductSweep(
            factors=[_sweep_zip_to_proto(cast(cirq.Zip, factor)) for factor in sweep.factors]
        )
    msg = params_pb2.ParameterSweep(repetitions=repetitions, sweep=product_sweep)
    return msg
Converts sweep into an equivalent protobuf representation.
cirq-google/cirq_google/api/v1/params.py