Pseudo code for VAR: Visual Autoregressive Modeling: Scalable Image Generation via Next-Scale Prediction
![image](https://private-user-images.githubusercontent.com/26713992/333987638-f40a6835-07e3-4c6d-843d-c10eaa1a45dc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQzNzAzMjMsIm5iZiI6MTcyNDM3MDAyMywicGF0aCI6Ii8yNjcxMzk5Mi8zMzM5ODc2MzgtZjQwYTY4MzUtMDdlMy00YzZkLTg0M2QtYzEwZWFhMWE0NWRjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIyVDIzNDAyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTljYjRkMGEzOGQ2NDk1YTk4ODE4NzdkYzZkM2FlMmU2ZWM5NTcyODRkNmZmNDQzNGQ0ODc0YzBiOTg2YmJlNjEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.t0ZofeQYblzB9KW70Ito-k1tOe5k3E7aoi0knevMbNQ)
![image](https://private-user-images.githubusercontent.com/26713992/333988269-83b60be1-a60a-4020-b453-aa90d7d1c0f2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQzNzAzMjMsIm5iZiI6MTcyNDM3MD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WC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZjOWMyZjQ2Y2I5N2M4NDMwYTlkNDU5MmE1OTllNTM0OGUwNTMyY2NlOTI1ZTg1MjcyOTVjYjI2NWM3NmVlOGQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.VDgnuq7DZxjrOXL0bsOYIob3hWWozuOG-3oFjUJWtHM)
vqvae_loss = vqvae_training(img, patch_nums)
print('vqvae training finish')
![image](https://private-user-images.githubusercontent.com/26713992/333988093-d92f3289-7fcb-4ed7-bfa5-e426ed621e2c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQzNzAzMjMsIm5iZiI6MTcyNDM3MDAyMywicGF0aCI6Ii8yNjcxMzk5Mi8zMzM5ODgwOTMtZDkyZjMyODktN2ZjYi00ZWQ3LWJmYTUtZTQyNmVkNjIxZTJjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIyVDIzNDAyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWIwNjU4YWI4NDJmNDI1NjIxYzVhOWUzYjdkOWE0ZThlYTBjNDdkYjhmZDczOTQ4MDI3ZTE1MjIwYmM1NzNjNjQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.NzfVlTatt3RTxag6S83XPoMzOxs6-4shs7cY5wamHfg)
var_loss = var_training(img, patch_nums, class_label)
print('var training finish')
![image](https://private-user-images.githubusercontent.com/26713992/333990767-4f07af30-c234-4d4b-87e5-68eb43569a16.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQzNzAzMjMsIm5iZiI6MTcyNDM3MDAyMywicGF0aCI6Ii8yNjcxMzk5Mi8zMzM5OTA3NjctNGYwN2FmMzAtYzIzNC00ZDRiLTg3ZTUtNjhlYjQzNTY5YTE2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIyVDIzNDAyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZjMTRhNGExYWNlMDQ4ZWEwYjEwY2UxMGFiMjlhMTg4M2Y3OWVkYTIwM2ViZTA4YjNmODZjM2RlYWY0ZTJjOTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.DWdbFbXwx1IEGJP1fsoKux5Aq2lvMamNbijsHcMddAw)
generated_image = var_inference(class_label, patch_nums)
print('Generate image: ', generated_image.shape)