<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def convert_labels(Y, source, dest):
 """Convert a matrix from one label type to another Args: Y: A np.ndarray or torch.Tensor of labels (ints) source: The convention the labels are currently expressed in dest: The convention to convert the labels to Conventions: 'categorical': [0: abstain, 1: positive, 2: negative] 'plusminus': [0: abstain, 1: positive, -1: negative] 'onezero': [0: negative, 1: positive] Note that converting to 'onezero' will combine abstain and negative labels. """

    if Y is None:
        return Y
    if isinstance(Y, np.ndarray):
        Y = Y.copy()
        assert isinstance(Y, int)
    elif isinstance(Y, torch.Tensor):
        Y = Y.clone()
        assert np.sum(Y.numpy() - Y.numpy().astype(int)) == 0.0
    else:
        raise ValueError("Unrecognized label data type.")
    negative_map = {"categorical": 2, "plusminus": -1, "onezero": 0}
    Y[Y == negative_map[source]] = negative_map[dest]
    return Y