def convert_device_id_to_int(device: str):
    """maps the string device, 'cpu', 'cuda', 'cuda:#'
    to an int for HF pipelines device representation

    Args:
        device (str, optional): No default.

    Raises:
        ValueError: _description_
        TypeError: _description_

    Returns:
        _type_: _description_
    """
    if device[:4] not in ['cpu', 'cuda']:
        raise ValueError(f"expected one of cpu or cuda or cuda:# but received {device}")

    if device == 'cpu':
        return -1
    
    if device == 'cuda':
        return 0

    if device.startswith('cuda:'):
        # check if it is id'd by number
        if device[-1].isnumeric():
            return int(device.replace('cuda:', ''))
    
    raise TypeError(f"unexpected device {device}")
maps the string device, 'cpu', 'cuda', 'cuda:#'
    to an int for HF pipelines device representation

    Args:
        device (str, optional): No default.

    Raises:
        ValueError: _description_
        TypeError: _description_

    Returns:
        _type_: _description_
    
src/marqo/s2_inference/reranking/model_utils.py