class_docstr: Base `tts` class. Every new `tts` model must inherit this.
  
  It defines common `tts` specific functions on top of `Model` implementation.
class_docstr_tok: ["Base","`","tts","`","class",".","Every","new","`","tts","`","model","must","inherit","this",".","It","defines","common","`","tts","`","specific","functions","on","top","of","`","Model","`","implementation","."]
docstr: Initialize a speaker embedding layer if needen and define expected embedding channel size for defining
  `in_channels` size of the connected layers.
  
  This implementation yields 3 possible outcomes:
  
  1. If `config.use_speaker_embedding` and `config.use_d_vector_file are False, do nothing.
  2. If `config.use_d_vector_file` is True, set expected embedding channel size to `config.d_vector_dim` or 512.
  3. If `config.use_speaker_embedding`, initialize a speaker embedding layer with channel size of
  `config.d_vector_dim` or 512.
  
  You can override this function for new models.
  
  Args:
      config (Coqpit): Model configuration.
docstr_tok: ["Initialize","a","speaker","embedding","layer","if","needen","and","define","expected","embedding","channel","size","for","defining","`","in_channels","`","size","of","the","connected","layers",".","This","implementation","yields","3","possible","outcomes",":","1",".","If","`","config.use_speaker_embedding","`","and","`","config.use_d_vector_file","are","False",",","do","nothing",".","2",".","If","`","config.use_d_vector_file","`","is","True",",","set","expected","embedding","channel","size","to","`","config.d_vector_dim","`","or","512",".","3",".","If","`","config.use_speaker_embedding","`",",","initialize","a","speaker","embedding","layer","with","channel","size","of","`","config.d_vector_dim","`","or","512",".","You","can","override","this","function","for","new","models",".","Args",":","config","(","Coqpit",")",":","Model","configuration","."]
code: def init_multispeaker(self, config: Coqpit, data: List = None):
      """Initialize a speaker embedding layer if needen and define expected embedding channel size for defining
      `in_channels` size of the connected layers.
  
      This implementation yields 3 possible outcomes:
  
      1. If `config.use_speaker_embedding` and `config.use_d_vector_file are False, do nothing.
      2. If `config.use_d_vector_file` is True, set expected embedding channel size to `config.d_vector_dim` or 512.
      3. If `config.use_speaker_embedding`, initialize a speaker embedding layer with channel size of
      `config.d_vector_dim` or 512.
  
      You can override this function for new models.
  
      Args:
          config (Coqpit): Model configuration.
      """
      # set number of speakers
      if self.speaker_manager is not None:
          self.num_speakers = self.speaker_manager.num_speakers
      elif hasattr(config, "num_speakers"):
          self.num_speakers = config.num_speakers
  
      # set ultimate speaker embedding size
      if config.use_speaker_embedding or config.use_d_vector_file:
          self.embedded_speaker_dim = (
              config.d_vector_dim
              if "d_vector_dim" in config
              and config.d_vector_dim is not None
              else 512
          )
      # init speaker embedding layer
      if config.use_speaker_embedding and not config.use_d_vector_file:
          print(" > Init speaker_embedding layer.")
          self.speaker_embedding = nn.Embedding(
              self.num_speakers, self.embedded_speaker_dim
          )
          self.speaker_embedding.weight.data.normal_(0, 0.3)
  
imports: import os
  import random
  from typing import Dict, List, Tuple, Union
  import torch
  import torch.distributed
  from coqpit import Coqpit
  from torch import nn
  from torch.utils.data import DataLoader
  from torch.utils.data.sampler import WeightedRandomSampler
  from trainer.torch import DistributedSampler, DistributedSamplerWrapper
  from TTS.model import BaseTrainerModel
  from TTS.tts.datasets.dataset import TTSDataset
  from TTS.tts.utils.data import get_length_balancer_weights
  from TTS.tts.utils.languages import LanguageManager, get_language_balancer_weights
  from TTS.tts.utils.speakers import SpeakerManager, get_speaker_balancer_weights, get_speaker_manager
  from TTS.tts.utils.synthesis import synthesis
  from TTS.tts.utils.visual import plot_alignment, plot_spectrogram
label_desc: Use image node_id 3 for calling the BaseTTS obj's underlying member method code with example usage: obj.init_multispeaker(config, data) without return types