There is no absolute mechanism or formula for that. One attempts to negotiate a fair sharing of the costs. Large teams from countries with wealthy economies are expected to carry a larger share of the costs than small teams from countries with still developing economies. Consideration of the possible contributions of teams/countries is a central part of the process of forming the collaboration.