class_docstr: Base class shared by Tacotron and Tacotron2
docstr: Compute global style token
docstr_tok: ["Compute","global","style","token"]
code: def compute_gst(self, inputs, style_input, speaker_embedding=None):
      """Compute global style token"""
      if isinstance(style_input, dict):
          # multiply each style token with a weight
          query = torch.zeros(
              1, 1, self.gst.gst_embedding_dim // 2
          ).type_as(inputs)
          if speaker_embedding is not None:
              query = torch.cat(
                  [query, speaker_embedding.reshape(1, 1, -1)], dim=-1
              )
  
          _GST = torch.tanh(
              self.gst_layer.style_token_layer.style_tokens
          )
          gst_outputs = torch.zeros(
              1, 1, self.gst.gst_embedding_dim
          ).type_as(inputs)
          for k_token, v_amplifier in style_input.items():
              key = _GST[int(k_token)].unsqueeze(0).expand(1, -1, -1)
              gst_outputs_att = (
                  self.gst_layer.style_token_layer.attention(query, key)
              )
              gst_outputs = gst_outputs + gst_outputs_att * v_amplifier
      elif style_input is None:
          # ignore style token and return zero tensor
          gst_outputs = torch.zeros(
              1, 1, self.gst.gst_embedding_dim
          ).type_as(inputs)
      else:
          # compute style tokens
          gst_outputs = self.gst_layer(
              style_input, speaker_embedding
          )  # pylint: disable=not-callable
      inputs = self._concat_speaker_embedding(inputs, gst_outputs)
      return inputs
  
imports: import copy
  from abc import abstractmethod
  from typing import Dict, Tuple
  import torch
  from coqpit import Coqpit
  from torch import nn
  from TTS.tts.layers.losses import TacotronLoss
  from TTS.tts.models.base_tts import BaseTTS
  from TTS.tts.utils.helpers import sequence_mask
  from TTS.tts.utils.speakers import SpeakerManager
  from TTS.tts.utils.synthesis import synthesis
  from TTS.tts.utils.text.tokenizer import TTSTokenizer
  from TTS.tts.utils.visual import plot_alignment, plot_spectrogram
  from TTS.utils.generic_utils import format_aux_input
  from TTS.utils.io import load_fsspec
  from TTS.utils.training import gradual_training_scheduler
label_desc: Use image node_id 15 for calling the BaseTacotron obj's underlying member method code with example usage: obj.compute_gst(inputs, style_input, speaker_embedding) and returns: inputs