<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _fix_valid_indices(cls, valid_indices, insertion_index, dim):
 """Add indices for H&S inserted elements."""

        # TODO: make this accept an immutable sequence for valid_indices
        # (a tuple) and return an immutable sequence rather than mutating an
        # argument.
        indices = np.array(sorted(valid_indices[dim]))
        slice_index = np.sum(indices <= insertion_index)
        indices[slice_index:] += 1
        indices = np.insert(indices, slice_index, insertion_index + 1)
        valid_indices[dim] = indices.tolist()
        return valid_indices