def to_numpy(tensor):
    """
    Convert a tensor, either a Torch or TensorFlow tensor, to a numpy tensor
    """
    if 'detach' in dir(tensor):
        # It's torch
        return tensor.cpu().detach().numpy()
    else:
        # It's tensorflow
        return tensor.numpy()