This building cannot (can't) be a hospital in the town.
この建物は町の病院のはずはない。
↓
This building cannot (can't) have been a hospital in the town.
この建物は町の病院だったはずはない。
He cannot (can't) be a popular person in the class.
彼はクラスの人気者のはずはない。
↓
He cannot (can't) have been a popular person in the class.
彼はクラスの人気者だったはずはない。
【解説】
This building couldn't be a hospital in the town.
「この建物は町の病院のはずはない」
He couldn't be a popular person in the class.
「彼はクラスの人気者のはずはない」
このようにcouldを使うとcanと同じ推量になってしまうため、推量の過去形は完了形で表す。