keras/src/backend/common/variables.py/KerasVariable/__float__
class KerasVariable:    def __float__(self):
        if self.ndim > 0:
            raise TypeError(
                "Only scalar arrays can be converted to Python scalars. "
                f"Got: shape={self.shape}"
            )
        return float(self.value)