def build()

in basic_pitch/layers/signal.py [0:0]


    def build(self, input_shape: tf.TensorShape) -> None:
        if self.window_length < self.fft_length:
            lpad = (self.fft_length - self.window_length) // 2
            rpad = self.fft_length - self.window_length - lpad

            def padded_window(window_length: int, dtype: tf.dtypes.DType = tf.float32) -> tf.Tensor:
                # This is a trick to match librosa's way of handling window lengths < their fft_lengths
                # In that case the window is 0 padded such that the window is centered around 0s
                # In the Tensorflow case, the window is computed, multiplied against the frame and then
                # Right padded with 0's.
                return tf.pad(self.window_fn(self.window_length, dtype=dtype), [[lpad, rpad]])  # type: ignore

            self.final_window_fn = padded_window

        if self.center:
            self.spec = tf.keras.layers.Lambda(
                lambda x: tf.pad(
                    x,
                    [[0, 0] for _ in range(input_shape.rank - 1)] + [[self.fft_length // 2, self.fft_length // 2]],
                    mode=self.pad_mode,
                )
            )
        else:
            self.spec = tf.keras.layers.Lambda(lambda x: x)