def to_sweeps(sweepable: Sweepable, metadata: dict | None = None) -> list[Sweep]:
    """Converts a Sweepable to a list of Sweeps."""
    if sweepable is None:
        return [UnitSweep]
    if isinstance(sweepable, ParamResolver):
        return [_resolver_to_sweep(sweepable, metadata)]
    if isinstance(sweepable, Sweep):
        return [sweepable]
    if isinstance(sweepable, dict):
        if any(isinstance(val, Sequence) for val in sweepable.values()):
            warnings.warn(
                'Implicit expansion of a dictionary into a Cartesian product '
                'of sweeps is deprecated and will be removed in cirq 0.10. '
                'Instead, expand the sweep explicitly using '
                '`cirq.dict_to_product_sweep`.',
                DeprecationWarning,
                stacklevel=2,
            )
        product_sweep = dict_to_product_sweep(sweepable)
        return [_resolver_to_sweep(resolver, metadata) for resolver in product_sweep]
    if isinstance(sweepable, Iterable) and not isinstance(sweepable, str):
        return [sweep for item in sweepable for sweep in to_sweeps(item, metadata)]
    raise TypeError(f'Unrecognized sweepable type: {type(sweepable)}.\nsweepable: {sweepable}')
Converts a Sweepable to a list of Sweeps.
cirq-core/cirq/study/sweepable.py