private Model retypeListsBackToSets(
            ModelTransformer transformer,
            Model model,
            Set<SetShape> sets,
            Map<ShapeId, ShapeId> renamed
    ) {
        if (sets.isEmpty()) {
            return model;
        }

        Map<ShapeId, ShapeType> retype = new HashMap<>(sets.size());
        for (SetShape shape : sets) {
            ShapeId renamedId = renamed.getOrDefault(shape.getId(), shape.getId());
            retype.put(renamedId, ShapeType.SET);
        }

        return transformer.changeShapeType(model, retype);
    }
Renames shapes using ShapeId pairs while ensuring that the
 transformed model is in a consistent state.

 <p>Member shapes are updated when their containing shape is updated.

 <p>Trait references to ShapeId values are also updated.
smithy-model/src/main/java/software/amazon/smithy/model/transform/RenameShapes.java