def needs_batch_dim(image):
    """Determines whether an image has or is missing a batch dimension."""
    if not hasattr(image, 'shape'):
        raise TypeError(
            "Can only determine batch dimensions for numpy arrays or tensors.")
    if len(image.shape) == 2:
        return True
    elif len(image.shape) == 3:
        if image.shape[0] != 1:
            return True
    return False