train_dataset = train_dataset.map(compute_embeddings_fn, batched=True, new_fingerprint=new_fingerprint)
train_dataset = train_dataset.map(
compute_vae_encodings_fn,
batched=True,
batch_size=args.train_batch_size * accelerator.num_processes * args.gradient_accumulation_steps,
new_fingerprint=new_fingerprint_for_vae,
)
```  
After calculating the embeddings, the text encoder, VAE, and tokenizer are deleted to free up some memory:  
```py
del text_encoders, tokenizers, vae
gc.collect()