def get_guidance_scale_embedding(
        self, w: torch.Tensor, embedding_dim: int = 512, dtype: torch.dtype = torch.float32
    ):
        """Gets the guidance scale embedding for classifier free guidance conditioning.
        See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298

        Args:
            w (`torch.Tensor`):
                The guidance scale tensor used for classifier free guidance conditioning.
            embedding_dim (`int`, defaults to 512):
                The dimensionality of the guidance scale embedding.
            dtype (`torch.dtype`, defaults to torch.float32):
                The dtype of the embedding.

        Returns:
            `torch.Tensor`: Embedding vectors with shape `(len(w), embedding_dim)`.
        """
        assert len(w.shape) == 1
        w = w * 1000.0

        half_dim = embedding_dim // 2
        emb = torch.log(torch.tensor(10000.0)) / (half_dim - 1)
        emb = torch.exp(torch.arange(half_dim, dtype=dtype) * -emb)
        emb = w.to(dtype)[:, None] * emb[None, :]
        emb = torch.cat([torch.sin(emb), torch.cos(emb)], dim=1)
        if embedding_dim % 2 == 1:  # zero pad
            emb = torch.nn.functional.pad(emb, (0, 1))
        assert emb.shape == (w.shape[0], embedding_dim)
        return emb
Gets the guidance scale embedding for classifier free guidance conditioning.
        See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298

        Args:
            w (`torch.Tensor`):
                The guidance scale tensor used for classifier free guidance conditioning.
            embedding_dim (`int`, defaults to 512):
                The dimensionality of the guidance scale embedding.
            dtype (`torch.dtype`, defaults to torch.float32):
                The dtype of the embedding.

        Returns:
            `torch.Tensor`: Embedding vectors with shape `(len(w), embedding_dim)`.
        
examples/community/regional_prompting_stable_diffusion.py