import tensorflow as tf

        :returns: Tensor of same shape as expanded_tensor, but with `value_if_masked` filled
            in masked dimensions.
        """
        mask_shape = list(map(int, self.mask.shape))
        graph_typecheck.assert_shape(expanded_tensor, mask_shape + expected_extra_dims)

        value_if_masked = expanded_tensor.dtype.as_numpy_dtype(value_if_masked)
        if_masked_tensor = tf.fill(expanded_tensor.shape, value_if_masked)
        mask = self.mask
        for i in range(2, 2 + len(expected_extra_dims)):
            mask = tf.expand_dims(mask, axis=i)
        mask = tf.tile(mask, [1, 1] + expected_extra_dims)
        return tf.where(mask, expanded_tensor, if_masked_tensor)


def initial_layer(
    window_feature: WindowFeatures, *, clip_magnitude=10.0, include_flux_and_time=False
) -> tf.Tensor:
    features = tf.expand_dims(window_feature.dflux_dt(clip_magnitude=clip_magnitude), 2)
    if include_flux_and_time:
        dflux = tf.expand_dims(window_feature.dflux, 2)
        dtime = tf.expand_dims(window_feature.dtime, 2)
