# AutoencoderKLLTX2Audio

[LTX-2](https://huggingface.co/Lightricks/LTX-2)で使用されているKL損失付き3次元変分オートエンコーダ（VAE）モデルは、Lightricksによって導入されました。これは、音声の潜在表現をエンコードおよびデコードするために使用されます。

モデルは、以下のコードスニペットで読み込むことができます。

```python
from diffusers import AutoencoderKLLTX2Audio

vae = AutoencoderKLLTX2Audio.from_pretrained("Lightricks/LTX-2", subfolder="vae", dtype=torch.float32).to("cuda")  # or "mps", "xpu", "cpu"
```

## AutoencoderKLLTX2Audio[[diffusers.AutoencoderKLLTX2Audio]]

#### diffusers.AutoencoderKLLTX2Audio[[diffusers.AutoencoderKLLTX2Audio]]

```python
diffusers.AutoencoderKLLTX2Audio(base_channels: int = 128, output_channels: int = 2, ch_mult: tuple[int, ...] = (1, 2, 4), num_res_blocks: int = 2, attn_resolutions: tuple[int, ...] | None = None, in_channels: int = 2, resolution: int = 256, latent_channels: int = 8, norm_type: str = 'pixel', causality_axis: str | None = 'height', dropout: float = 0.0, mid_block_add_attention: bool = False, sample_rate: int = 16000, mel_hop_length: int = 160, is_causal: bool = True, mel_bins: int | None = 64, double_z: bool = True)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/autoencoder_kl_ltx2_audio.py#L668)

LTX2のオーディオVAE。オーディオの潜在表現のエンコードとデコードに使用します。

#### encode[[diffusers.AutoencoderKLLTX2Audio.encode]]

```python
encode(x: Tensor, return_dict: bool = True)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/autoencoder_kl_ltx2_audio.py#L759)

#### decode[[diffusers.AutoencoderKLLTX2Audio.decode]]

```python
decode(z: Tensor, return_dict: bool = True)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/autoencoder_kl_ltx2_audio.py#L775)

#### forward[[diffusers.AutoencoderKLLTX2Audio.forward]]

```python
forward(sample: Tensor, sample_posterior: bool = False, return_dict: bool = True, generator: typing.Optional[torch.Generator] = None)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/autoencoder_kl_ltx2_audio.py#L788)

**パラメータ:**

sample (`torch.Tensor`) : 入力サンプル。

sample_posterior (`bool`、*任意*、デフォルトは`False`) : 事後分布からサンプリングするかどうか。

return_dict (`bool`、*任意*、デフォルトは`True`) : プレーンなタプルではなく`DecoderOutput`を返すかどうか。

generator (`torch.Generator`, *任意*) : サンプリングを決定論的にするための [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html)。

**戻り値:** `DecoderOutput` または `tuple`

`return_dict` が True の場合、`DecoderOutput` が返され、それ以外の場合は通常の `tuple` が返されます。

