class_docstr: This is copied from 🐸TTS to remove it from the dependencies.
code: def load_checkpoint(
      self,
      checkpoint_path: str,
      eval: bool = False,
      use_cuda: bool = False,
      criterion=None,
      cache=False,
  ):
      state = load_fsspec(
          checkpoint_path, map_location=torch.device("cpu"), cache=cache
      )
      try:
          self.load_state_dict(state["model"])
          print(" > Model fully restored. ")
      except (KeyError, RuntimeError) as error:
          # If eval raise the error
          if eval:
              raise error
  
          print(" > Partial model initialization.")
          model_dict = self.state_dict()
          model_dict = set_init_dict(model_dict, state["model"])
          self.load_state_dict(model_dict)
          del model_dict
  
      # load the criterion for restore_path
      if criterion is not None and "criterion" in state:
          try:
              criterion.load_state_dict(state["criterion"])
          except (KeyError, RuntimeError) as error:
              print(" > Criterion load ignored because of:", error)
  
      if use_cuda:
          self.cuda()
          if criterion is not None:
              criterion = criterion.cuda()
  
      if eval:
          self.eval()
          assert not self.training
  
      if not eval:
          return criterion, state["step"]
      return criterion
  
imports: import torch
  import torchaudio
  from torch import nn
  from torch.nn import Conv1d, ConvTranspose1d
  from torch.nn import functional
  from torch.nn.utils.parametrizations import weight_norm
  from torch.nn.utils.parametrize import remove_parametrizations
  from TTS.utils.io import load_fsspec
label_desc: Use image node_id 6 for calling the ResNetSpeakerEncoder obj's underlying member method code with example usage: obj.load_checkpoint(checkpoint_path, eval, use_cuda, criterion, cache) and returns: criterion, criterion,  state