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: Extend mask, from reduced number of frequency bin to
  the number of frequency bin in the STFT.
  
  Parameters:
      mask (tf.Tensor):
          Restricted mask.
  
  Returns:
      tf.Tensor:
          Extended mask
  
  Raises:
      ValueError:
          If invalid mask_extension parameter is set.
docstr_tok: ["Extend","mask",",","from","reduced","number","of","frequency","bin","to","the","number","of","frequency","bin","in","the","STFT",".","Parameters",":","mask","(","tf.Tensor",")",":","Restricted","mask",".","Returns",":","tf.Tensor",":","Extended","mask","Raises",":","ValueError",":","If","invalid","mask_extension","parameter","is","set","."]
code: def _extend_mask(self, mask: tf.Tensor) -> tf.Tensor:
      """
      Extend mask, from reduced number of frequency bin to
      the number of frequency bin in the STFT.
  
      Parameters:
          mask (tf.Tensor):
              Restricted mask.
  
      Returns:
          tf.Tensor:
              Extended mask
  
      Raises:
          ValueError:
              If invalid mask_extension parameter is set.
      """
      extension = self._params["mask_extension"]
      # Extend with average
      # (dispatch according to energy in the processed band)
      if extension == "average":
          extension_row = tf.reduce_mean(mask, axis=2, keepdims=True)
      # Extend with 0
      # (avoid extension artifacts but not conservative separation)
      elif extension == "zeros":
          mask_shape = tf.shape(mask)
          extension_row = tf.zeros(
              (mask_shape[0], mask_shape[1], 1, mask_shape[-1])
          )
      else:
          raise ValueError(
              f"Invalid mask_extension parameter {extension}"
          )
      n_extra_row = self._frame_length // 2 + 1 - self._F
      extension = tf.tile(extension_row, [1, 1, n_extra_row, 1])
      return tf.concat([mask, extension], axis=2)
  
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 17 for calling the EstimatorSpecBuilder obj's underlying member method code with example usage: obj._extend_mask(mask) and returns: tf