def val(val: Im2LatexDataset, model: ResNetV2, num_samples=400, device='cuda') -> float:
    """Evaluate the model on a dataset

    Args:
        val (Im2LatexDataset): Validation dataset
        model (ResNetV2): Model to evaluate
        num_samples (int, optional): Number of samples to evaluate on. Defaults to 400.
        device (str, optional): Torch device. Defaults to 'cuda'.

    Returns:
        float: Accuracy
    """
    model.eval()
    c, t = 0, 0
    iter(val)
    with torch.no_grad():
        for i in range(num_samples):
            im, l = prepare_data(val)
            if im is None:
                continue
            p = model(im.to(device)).argmax(-1).detach().cpu().numpy()
            c += (p == l[0].item()).sum()
            t += len(im)
    model.train()
    return c/t
Evaluate the model on a dataset

    Args:
        val (Im2LatexDataset): Validation dataset
        model (ResNetV2): Model to evaluate
        num_samples (int, optional): Number of samples to evaluate on. Defaults to 400.
        device (str, optional): Torch device. Defaults to 'cuda'.

    Returns:
        float: Accuracy
    
pix2tex/train_resizer.py