<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def neighbor(pos, tune_params):
 """return a random neighbor of pos"""

    size = len(pos)
    pos_out = []
    # random mutation
    # expected value is set that values all dimensions attempt to get mutated
    for i in range(size):
        key = list(tune_params.keys())[i]
        values = tune_params[key]

        if random.random() < 0.2:  #replace with random value
            new_value = random_val(i, tune_params)
        else: #adjacent value
            ind = values.index(pos[i])
            if random.random() > 0.5:
                ind += 1
            else:
                ind -= 1
            ind = min(max(ind, 0), len(values)-1)
            new_value = values[ind]

        pos_out.append(new_value)
    return pos_out