def METHOD_NAME(self, xp, dtype):
    a = xp.array(self.array, dtype=dtype)
    y = xp.linalg.matrix_rank(a, tol=self.tol)
    if xp is cupy:
        assert isinstance(y, cupy.ndarray)
        assert y.shape == ()
    else:
        # Note numpy returns numpy scalar or python int
        y = xp.array(y)
    return y