class_docstr: A builder class that allows to builds a multitrack unet model
  estimator. The built model estimator has a different behaviour when
  used in a train/eval mode and in predict mode.
  
  * In train/eval mode:
      It takes as input and outputs magnitude spectrogram
  * In predict mode:
      It takes as input and outputs waveform.
      The whole separation process is then done in this function
      for performance reason: it makes it possible to run the whole
      separation process (including STFT and inverse STFT) on GPU.
  
  Example:
  >>> from spleeter.model import EstimatorSpecBuilder
  >>> builder = EstimatorSpecBuilder()
  >>> builder.build_predict_model()
  >>> builder.build_evaluation_model()
  >>> builder.build_train_model()
  
  >>> from spleeter.model import model_fn
  >>> estimator = tf.estimator.Estimator(model_fn=model_fn, ...)
class_docstr_tok: ["A","builder","class","that","allows","to","builds","a","multitrack","unet","model","estimator",".","The","built","model","estimator","has","a","different","behaviour","when","used","in","a","train\/eval","mode","and","in","predict","mode",".","*","In","train\/eval","mode",":","It","takes","as","input","and","outputs","magnitude","spectrogram","*","In","predict","mode",":","It","takes","as","input","and","outputs","waveform",".","The","whole","separation","process","is","then","done","in","this","function","for","performance","reason",":","it","makes","it","possible","to","run","the","whole","separation","process","(","including","STFT","and","inverse","STFT",")","on","GPU",".","Example",":",">",">",">","from","spleeter.model","import","EstimatorSpecBuilder",">",">",">","builder","=","EstimatorSpecBuilder","(",")",">",">",">","builder.build_predict_model","(",")",">",">",">","builder.build_evaluation_model","(",")",">",">",">","builder.build_train_model","(",")",">",">",">","from","spleeter.model","import","model_fn",">",">",">","estimator","=","tf.estimator.Estimator","(","model_fn=model_fn",",","...",")"]
docstr: Builder interface for creating model instance that aims to perform
  model training. The output of such estimator will be a dictionary
  with a key "<instrument>_spectrogram" per separated instrument,
  associated to the estimated separated instrument magnitude spectrogram.
  
  Parameters:
      labels (Dict):
          Model labels.
  
  Returns:
      tf.Tensor:
          An estimator for performing model training.
docstr_tok: ["Builder","interface","for","creating","model","instance","that","aims","to","perform","model","training",".","The","output","of","such","estimator","will","be","a","dictionary","with","a","key","``","<","instrument",">","_spectrogram","''","per","separated","instrument",",","associated","to","the","estimated","separated","instrument","magnitude","spectrogram",".","Parameters",":","labels","(","Dict",")",":","Model","labels",".","Returns",":","tf.Tensor",":","An","estimator","for","performing","model","training","."]
code: def build_train_model(self, labels: Dict) -> tf.Tensor:
      """
      Builder interface for creating model instance that aims to perform
      model training. The output of such estimator will be a dictionary
      with a key "<instrument>_spectrogram" per separated instrument,
      associated to the estimated separated instrument magnitude spectrogram.
  
      Parameters:
          labels (Dict):
              Model labels.
  
      Returns:
          tf.Tensor:
              An estimator for performing model training.
      """
      loss, metrics = self._build_loss(labels)
      optimizer = self._build_optimizer()
      train_operation = optimizer.minimize(
          loss=loss, global_step=tf.compat.v1.train.get_global_step()
      )
      return tf.estimator.EstimatorSpec(
          mode=tf.estimator.ModeKeys.TRAIN,
          loss=loss,
          train_op=train_operation,
          eval_metric_ops=metrics,
      )
  
imports: import importlib
  from typing import Any, Dict, Optional, Tuple
  import tensorflow
  from tensorflow.signal import hann_window, inverse_stft, stft
  from ..utils.tensor import pad_and_partition, pad_and_reshape
label_desc: Use image node_id 25 for calling the EstimatorSpecBuilder obj's underlying member method code with example usage: obj.build_train_model(labels) and returns: tf