Python code updated to generate cascaded samples