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: Compute masks from the output spectrograms of the model.
docstr_tok: ["Compute","masks","from","the","output","spectrograms","of","the","model","."]
code: def _build_masks(self):
      """
      Compute masks from the output spectrograms of the model.
      """
      output_dict = self.model_outputs
      stft_feature = self.stft_feature
      separation_exponent = self._params["separation_exponent"]
      output_sum = (
          tf.reduce_sum(
              [e**separation_exponent for e in output_dict.values()],
              axis=0,
          )
          + self.EPSILON
      )
      out = {}
      for instrument in self._instruments:
          output = output_dict[f"{instrument}_spectrogram"]
          # Compute mask with the model.
          instrument_mask = (
              output**separation_exponent
              + (self.EPSILON / len(output_dict))
          ) / output_sum
          # Extend mask;
          instrument_mask = self._extend_mask(instrument_mask)
          # Stack back mask.
          old_shape = tf.shape(instrument_mask)
          new_shape = tf.concat(
              [[old_shape[0] * old_shape[1]], old_shape[2:]], axis=0
          )
          instrument_mask = tf.reshape(instrument_mask, new_shape)
          # Remove padded part (for mask having the same size as STFT);
  
          instrument_mask = instrument_mask[
              : tf.shape(stft_feature)[0], ...
          ]
          out[instrument] = instrument_mask
      self._masks = out
  
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 18 for calling the EstimatorSpecBuilder obj's underlying member method code with example usage: obj._build_masks() without return types