def _generate_gaussian_weights(self, tile_width, tile_height, nbatches, device, dtype, sigma=0.05):
        """
        Generates Gaussian weights as a PyTorch tensor for blending tiles in latent space.

        Args:
            tile_width (int): Width of the tile in pixels.
            tile_height (int): Height of the tile in pixels.
            nbatches (int): Number of batches.
            device (torch.device): Device where the tensor will be allocated (e.g., 'cuda' or 'cpu').
            dtype (torch.dtype): Data type of the tensor (e.g., torch.float32).
            sigma (float, optional): Standard deviation of the Gaussian distribution. Controls the smoothness of the weights. Defaults to 0.05.

        Returns:
            torch.Tensor: A tensor containing Gaussian weights for blending tiles, expanded to match batch and channel dimensions.
        """
        # Convert tile dimensions to latent space
        latent_width = tile_width // 8
        latent_height = tile_height // 8

        # Generate Gaussian weights in latent space
        x = np.linspace(-1, 1, latent_width)
        y = np.linspace(-1, 1, latent_height)
        xx, yy = np.meshgrid(x, y)
        gaussian_weight = np.exp(-(xx**2 + yy**2) / (2 * sigma**2))

        # Convert to a PyTorch tensor with the correct device and dtype
        weights_torch = torch.tensor(gaussian_weight, device=device, dtype=dtype)

        # Expand for batch and channel dimensions
        weights_expanded = weights_torch.unsqueeze(0).unsqueeze(0)  # Add batch and channel dimensions
        weights_expanded = weights_expanded.expand(nbatches, -1, -1, -1)  # Expand to the number of batches

        return weights_expanded

        Generates Gaussian weights as a PyTorch tensor for blending tiles in latent space.

        Args:
            tile_width (int): Width of the tile in pixels.
            tile_height (int): Height of the tile in pixels.
            nbatches (int): Number of batches.
            device (torch.device): Device where the tensor will be allocated (e.g., 'cuda' or 'cpu').
            dtype (torch.dtype): Data type of the tensor (e.g., torch.float32).
            sigma (float, optional): Standard deviation of the Gaussian distribution. Controls the smoothness of the weights. Defaults to 0.05.

        Returns:
            torch.Tensor: A tensor containing Gaussian weights for blending tiles, expanded to match batch and channel dimensions.
        
examples/community/mod_controlnet_tile_sr_sdxl.py