def test_converting_to_device_parameters_diff_token_id_caching_is_correct() -> None:
    """Test that multiple calling of run_context.to_device_parameters_diff gives
    correct token id assignments.
    """
    device_params = [
        (
            run_context_pb2.DeviceParameter(
                path=["q1_2", "readout_default", "readoutDemodDelay"], units="ns"
            ),
            program_pb2.ArgValue(float_value=5.0),
        )
    ]

    diff = run_context.to_device_parameters_diff(device_params)
    expected_diff_pb_text = """
        groups {
          parent: -1
        }
        groups {
          name: 1
        }
        params {
          resource_group: 1
          name: 2
          value {
            float_value: 5
          }
        }
        strs: "q1_2"
        strs: "readout_default"
        strs: "readoutDemodDelay"
    """
    assert text_format.Parse(expected_diff_pb_text, run_context_pb2.DeviceParametersDiff()) == diff
Test that multiple calling of run_context.to_device_parameters_diff gives
    correct token id assignments.
    
cirq-google/cirq_google/api/v2/run_context_test.py