class_docstr: Tortoise model class.
  
  Currently only supports inference.
  
  Examples:
      >>> from TTS.tts.configs.tortoise_config import TortoiseConfig
      >>> from TTS.tts.models.tortoise import Tortoise
      >>> config = TortoiseConfig()
      >>> model = Tortoise.inif_from_config(config)
      >>> model.load_checkpoint(config, checkpoint_dir="paths/to/models_dir/", eval=True)
class_docstr_tok: ["Tortoise","model","class",".","Currently","only","supports","inference",".","Examples",":",">",">",">","from","TTS.tts.configs.tortoise_config","import","TortoiseConfig",">",">",">","from","TTS.tts.models.tortoise","import","Tortoise",">",">",">","config","=","TortoiseConfig","(",")",">",">",">","model","=","Tortoise.inif_from_config","(","config",")",">",">",">","model.load_checkpoint","(","config",",","checkpoint_dir=","''","paths\/to\/models_dir\/","''",",","eval=True",")"]
docstr: Load a model checkpoints from a directory. This model is with multiple checkpoint files and it
  expects to have all the files to be under the given `checkpoint_dir` with the rigth names.
  If eval is True, set the model to eval mode.
  
  Args:
      config (TortoiseConfig): The model config.
      checkpoint_dir (str): The directory where the checkpoints are stored.
      ar_checkpoint_path (str, optional): The path to the autoregressive checkpoint. Defaults to None.
      diff_checkpoint_path (str, optional): The path to the diffusion checkpoint. Defaults to None.
      clvp_checkpoint_path (str, optional): The path to the CLVP checkpoint. Defaults to None.
      vocoder_checkpoint_path (str, optional): The path to the vocoder checkpoint. Defaults to None.
      eval (bool, optional): Whether to set the model to eval mode. Defaults to False.
      strict (bool, optional): Whether to load the model strictly. Defaults to True.
docstr_tok: ["Load","a","model","checkpoints","from","a","directory",".","This","model","is","with","multiple","checkpoint","files","and","it","expects","to","have","all","the","files","to","be","under","the","given","`","checkpoint_dir","`","with","the","rigth","names",".","If","eval","is","True",",","set","the","model","to","eval","mode",".","Args",":","config","(","TortoiseConfig",")",":","The","model","config",".","checkpoint_dir","(","str",")",":","The","directory","where","the","checkpoints","are","stored",".","ar_checkpoint_path","(","str",",","optional",")",":","The","path","to","the","autoregressive","checkpoint",".","Defaults","to","None",".","diff_checkpoint_path","(","str",",","optional",")",":","The","path","to","the","diffusion","checkpoint",".","Defaults","to","None",".","clvp_checkpoint_path","(","str",",","optional",")",":","The","path","to","the","CLVP","checkpoint",".","Defaults","to","None",".","vocoder_checkpoint_path","(","str",",","optional",")",":","The","path","to","the","vocoder","checkpoint",".","Defaults","to","None",".","eval","(","bool",",","optional",")",":","Whether","to","set","the","model","to","eval","mode",".","Defaults","to","False",".","strict","(","bool",",","optional",")",":","Whether","to","load","the","model","strictly",".","Defaults","to","True","."]
code: def load_checkpoint(
      self,
      config,
      checkpoint_dir,
      ar_checkpoint_path=None,
      diff_checkpoint_path=None,
      clvp_checkpoint_path=None,
      vocoder_checkpoint_path=None,
      eval=False,
      strict=True,
      **kwargs,
  ):  # pylint: disable=unused-argument, redefined-builtin
      """Load a model checkpoints from a directory. This model is with multiple checkpoint files and it
      expects to have all the files to be under the given `checkpoint_dir` with the rigth names.
      If eval is True, set the model to eval mode.
  
      Args:
          config (TortoiseConfig): The model config.
          checkpoint_dir (str): The directory where the checkpoints are stored.
          ar_checkpoint_path (str, optional): The path to the autoregressive checkpoint. Defaults to None.
          diff_checkpoint_path (str, optional): The path to the diffusion checkpoint. Defaults to None.
          clvp_checkpoint_path (str, optional): The path to the CLVP checkpoint. Defaults to None.
          vocoder_checkpoint_path (str, optional): The path to the vocoder checkpoint. Defaults to None.
          eval (bool, optional): Whether to set the model to eval mode. Defaults to False.
          strict (bool, optional): Whether to load the model strictly. Defaults to True.
      """
      if self.models_dir is None:
          self.models_dir = checkpoint_dir
      ar_path = ar_checkpoint_path or os.path.join(
          checkpoint_dir, "autoregressive.pth"
      )
      diff_path = diff_checkpoint_path or os.path.join(
          checkpoint_dir, "diffusion_decoder.pth"
      )
      clvp_path = clvp_checkpoint_path or os.path.join(
          checkpoint_dir, "clvp2.pth"
      )
      vocoder_checkpoint_path = vocoder_checkpoint_path or os.path.join(
          checkpoint_dir, "vocoder.pth"
      )
      self.mel_norm_path = os.path.join(checkpoint_dir, "mel_norms.pth")
  
      if os.path.exists(ar_path):
          # remove keys from the checkpoint that are not in the model
          checkpoint = torch.load(
              ar_path, map_location=torch.device("cpu")
          )
  
          # strict set False
          # due to removed `bias` and `masked_bias` changes in Transformers
          self.autoregressive.load_state_dict(checkpoint, strict=False)
  
      if os.path.exists(diff_path):
          self.diffusion.load_state_dict(
              torch.load(diff_path), strict=strict
          )
  
      if os.path.exists(clvp_path):
          self.clvp.load_state_dict(
              torch.load(clvp_path), strict=strict
          )
  
      if os.path.exists(vocoder_checkpoint_path):
          self.vocoder.load_state_dict(
              config.model_args.vocoder.value.optionally_index(
                  torch.load(
                      vocoder_checkpoint_path,
                      map_location=torch.device("cpu"),
                  )
              )
          )
  
      if eval:
          self.autoregressive.post_init_gpt2_config(self.args.kv_cache)
          self.autoregressive.eval()
          self.diffusion.eval()
          self.clvp.eval()
          self.vocoder.eval()
  
imports: import os
  import random
  from contextlib import contextmanager
  from dataclasses import dataclass
  from time import time
  import torch
  import torch.nn.functional
  import torchaudio
  from coqpit import Coqpit
  from tqdm import tqdm
  from TTS.tts.layers.tortoise.arch_utils import TorchMelSpectrogram
  from TTS.tts.layers.tortoise.audio_utils import denormalize_tacotron_mel, load_voice, wav_to_univnet_mel
  from TTS.tts.layers.tortoise.autoregressive import UnifiedVoice
  from TTS.tts.layers.tortoise.classifier import AudioMiniEncoderWithClassifierHead
  from TTS.tts.layers.tortoise.clvp import CLVP
  from TTS.tts.layers.tortoise.diffusion import SpacedDiffusion, get_named_beta_schedule, space_timesteps
  from TTS.tts.layers.tortoise.diffusion_decoder import DiffusionTts
  from TTS.tts.layers.tortoise.random_latent_generator import RandomLatentConverter
  from TTS.tts.layers.tortoise.tokenizer import VoiceBpeTokenizer
  from TTS.tts.layers.tortoise.vocoder import VocConf, VocType
  from TTS.tts.layers.tortoise.wav2vec_alignment import Wav2VecAlignment
  from TTS.tts.models.base_tts import BaseTTS
label_desc: Use image node_id 11 for calling the Tortoise obj's underlying member method code with example usage: obj.load_checkpoint(config, checkpoint_dir, ar_checkpoint_path, diff_checkpoint_path, clvp_checkpoint_path, vocoder_checkpoint_path, eval, strict) without return types