The Partition function for topological field theories