def compute_validation_loss(params: AttributeDict, model: nn.Module, graph_compiler: CtcTrainingGraphCompiler, valid_dl: torch.utils.data.DataLoader, world_size: int=1) -> MetricsTracker:
    'Run the validation process. The validation loss\n    is saved in `params.valid_loss`.\n    '
    model.eval()
    tot_loss = MetricsTracker()
    for (batch_idx, batch) in enumerate(valid_dl):
        (loss, loss_info) = compute_loss(params=params, model=model, batch=batch, graph_compiler=graph_compiler, is_training=False)
        assert (loss.requires_grad is False)
        tot_loss = (tot_loss + loss_info)
    if (world_size > 1):
        tot_loss.reduce(loss.device)
    loss_value = (tot_loss['loss'] / tot_loss['frames'])
    if (loss_value < params.best_valid_loss):
        params.best_valid_epoch = params.cur_epoch
        params.best_valid_loss = loss_value
    return tot_loss
Run the validation process. The validation loss
is saved in `params.valid_loss`.
def compute_validation_loss(params: AttributeDict, model: nn.Module, graph_compiler: CtcTrainingGraphCompiler, valid_dl: torch.utils.data.DataLoader, world_size: int=1) -> MetricsTracker:
    'Run the validation process. The validation loss\n    is saved in `params.valid_loss`.\n    '
    model.eval()
    tot_loss = MetricsTracker()
    for (batch_idx, batch) in enumerate(valid_dl):
        (loss, loss_info) = compute_loss(params=params, model=model, batch=batch, graph_compiler=graph_compiler, is_training=False)
        assert (loss.requires_grad is False)
        tot_loss = (tot_loss + loss_info)
    if (world_size > 1):
        tot_loss.reduce(loss.device)
    loss_value = (tot_loss['loss'] / tot_loss['frames'])
    if (loss_value < params.best_valid_loss):
        params.best_valid_epoch = params.cur_epoch
        params.best_valid_loss = loss_value
    return tot_loss