def METHOD_NAME(problem):
    if isinstance(problem, (int, str)):
        return LibraryProblemData.objects.filter(problem_id=problem).exists()
    try:
        return bool(problem.libraryproblemdata)
    except LibraryProblemData.DoesNotExist:
        return False