The fee rate is not related to the confirmation status of the transaction.
As far as the bitcoin protocol is concerned, fee rate is simply
transaction fee (in sats)/transaction size (in bytes). So for a 100 byte transaction, paying 10000 satoshis as a fee, the fee rate is
10000/1000, or 10 sats/byte.
Currently, you have two possible fee rates: Segwit and non-segwit.
The Fee Rate/weight unit, instead of fee rate/byte, measure is intended to provide a consistent view of fee rates, regardless of whether a transaction has segwit inputs or not.
The calculation remains the same -
weight units/total fee gives you the fee rate per weight unit, with a non-segwit byte counting as 4 weight units, and a segwit byte counting as 1 (this is a simplification, full details are outside the scope of fee rates).
To calculate this using Bitcoin Core, simply get the transaction details via RPC. A decoded response contains a
weight field, which you then divide by the total fees paid to determine the fee rate per weight unit.
If a transaction has multiple inputs from distinct wallets, the fee is still paid at a transaction level - to determine how much of a fee was "paid" by a particular input, you'd need to determine who received the outputs, and where the change went. Once you know the output break up, you can attempt to distribute the total fee among the participants.