<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def build_idx_set(branch_id, start_date):
 """ Builds a dictionary of keys based on the branch code """

    code_set = branch_id.split("/")
    code_set.insert(3, "Rates")
    idx_set = {
        "sec": "/".join([code_set[0], code_set[1], "Sections"]),
        "mag": "/".join([code_set[0], code_set[1], code_set[2], "Magnitude"])}
    idx_set["rate"] = "/".join(code_set)
    idx_set["rake"] = "/".join([code_set[0], code_set[1], "Rake"])
    idx_set["msr"] = "-".join(code_set[:3])
    idx_set["geol"] = code_set[0]
    if start_date:  # time-dependent source
        idx_set["grid_key"] = "_".join(
            branch_id.replace("/", "_").split("_")[:-1])
    else:  # time-independent source
        idx_set["grid_key"] = branch_id.replace("/", "_")
    idx_set["total_key"] = branch_id.replace("/", "|")
    return idx_set