def predict_binary(model, x, thresh=0.5):
    """
    Predict a class (0, 1) for each input (first dimension of `x`) using the classifier  `model`.

    Args:
        model: binary classifier module that outputs a logit for every input sequence.
        x: input tensor.
        thresh: value of logits that separates positive (above thresh -> 1) and negative (below thresh -> 0) classes.
    Returns
        Integer tensor that contains the predicted classes (0 or 1). Its shape is the same as the output of the model.
    """
    preds = model(x).cpu()
    pred_classes = (preds > thresh).int()
    return pred_classes