def METHOD_NAME(self, target):
    if len(self.tgt_vocab) != len(self.vocab):
        def _filter(target):
            mask = target.ge(len(self.tgt_vocab))
            if mask.any():
                target[mask] = self.tgt_vocab.unk()
            return target
        if isinstance(target, list):
            return [_filter(t) for t in target]
        return _filter(target)
    return target