public static final Map<String, ShapeModel> removeUnusedShapes(IntermediateModel model) {

        Map<String, ShapeModel> out = new HashMap<String, ShapeModel>();
        Map<String, ShapeModel> in = model.getShapes();

        for(OperationModel opModel : model.getOperations().values()) {
            addOperationShapes(opModel, in, out);
        }

        return out;
    }
Removes the un-used shapes from the intermediate model. This is done by
re-constructing the shapes map. First add the shapes referenced by the
operations and then adding the shapes referenced by each shapes.
aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/RemoveUnusedShapes.java