def mix_fn(self, gold_tokens, sampled_tokens):
    """Mixes gold and sampled tokens randomly."""
    hparams = self._t2tmodel.hparams
    p_sample = inverse_decay_mix_prob(
        hparams.scheduled_sampling_warmup_schedule,
        hparams.scheduled_sampling_gold_mixin_prob,
        hparams.scheduled_sampling_warmup_steps)
    return _mix_tokens(
        p_sample=p_sample,
        gold_targets=gold_tokens,
        sampled_targets=sampled_tokens)
Mixes gold and sampled tokens randomly.
tensor2tensor/utils/scheduled_sampling.py