(2) The court shall, after giving its decision in a trial or on an application, in the absence of agreement, determine, either immediately or at a hearing fixed for the purpose which, if any, party should pay costs to another party and the quantum of such costs.