class_docstr: Wraps a ContinuousTransformerWrapper and applies CheckpointedLayer to each layer and permutes from channels-mid
  to channels-last that XTransformer expects.
class_docstr_tok: ["Wraps","a","ContinuousTransformerWrapper","and","applies","CheckpointedLayer","to","each","layer","and","permutes","from","channels-mid","to","channels-last","that","XTransformer","expects","."]
code: def __init__(
      self,
      needs_permute=True,
      exit_permute=True,
      checkpoint=True,
      **xtransformer_kwargs,
  ):
      super().__init__()
      self.transformer = ContinuousTransformerWrapper(
          **xtransformer_kwargs
      )
      self.needs_permute = needs_permute
      self.exit_permute = exit_permute
  
      if not checkpoint:
          return
      for i in range(len(self.transformer.attn_layers.layers)):
          n, b, r = self.transformer.attn_layers.layers[i]
          self.transformer.attn_layers.layers[i] = nn.ModuleList(
              [n, CheckpointedLayer(b), r]
          )
  
imports: import functools
  import math
  import os
  import fsspec
  import torch
  import torch.nn
  import torch.nn.functional
  import torchaudio
  from transformers import LogitsWarper
  from TTS.tts.layers.tortoise.xtransformers import ContinuousTransformerWrapper, RelativePositionBias
label_desc: Use image node_id 1 to create a new CheckpointedXTransformerEncoder object from inherited base classes: nn with example: obj = CheckpointedXTransformerEncoder(needs_permute, exit_permute, checkpoint)