def check_rank(shape, required_rank):
    """ Check if the shape's rank equals the expected rank """
    if isinstance(shape, tuple):
        return len(shape) == required_rank
    else:
        return False