def arch_sampling_str_to_dict(sampling_str):
    """
    Converts string representations of architecutre
    sampling methodology to the dictionary format
    that nas_searchmanager.SearchManager uses.

    Example:
    \"1:4,2:4,3:4,4:4\" is converted to
    {1.0 : 4, 2.0 : 4, 3.0 : 4, 4.0 : 4}.
    """

    # Remove any spaces that the user may have
    # entered into the string representation.
    sampling_str = sampling_str.replace(" ", "")

    # Split by comma to get the architectures sampled
    # at each number of architecture parameters epochs
    # completed.
    archs_sampled_list = sampling_str.split(",")

    # Convert the list of epoch:num_archs_to_sample
    # strings to the correct dictionary format.
    arch_sampling_dict = {}
    for curr_arch_sampling in archs_sampled_list:
        # Split by colon.
        [num_epochs_elapsed, num_archs_to_sample] = curr_arch_sampling.split(":")

        # Add to dictionary.
        arch_sampling_dict[float(num_epochs_elapsed)] = int(num_archs_to_sample)

    # Return the dictionary.
    return arch_sampling_dict