def forward_with_cfg(self, x, t, condition, cfg_scale):
        """
        Forward pass of ClassTransformer, but also batches the unconditional forward pass for classifier-free guidance.
        """
        # https://github.com/openai/glide-text2im/blob/main/notebooks/text2im.ipynb
        half = x[: len(x) // 2]
        combined = torch.cat([half, half], dim=0)
        eps = self.forward_diffusion(combined, t, condition)
        cond_eps, uncond_eps = torch.split(eps, len(eps) // 2, dim=0)
        half_eps = uncond_eps + cfg_scale * (cond_eps - uncond_eps)
        eps = torch.cat([half_eps, half_eps], dim=0)
        return eps

        Forward pass of ClassTransformer, but also batches the unconditional forward pass for classifier-free guidance.
        
LatentLM/models/Transformer.py