<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def expected_costs(self, class_probs, inst=None):
 """ Calculates the expected misclassification cost for each possible class value, given class probability estimates. :param class_probs: the class probabilities :type class_probs: ndarray :return: the calculated costs :rtype: ndarray """

        if inst is None:
            costs = javabridge.call(
                self.jobject, "expectedCosts", "([D)[D", javabridge.get_env().make_double_array(class_probs))
            return javabridge.get_env().get_double_array_elements(costs)
        else:
            costs = javabridge.call(
                self.jobject, "expectedCosts", "([DLweka/core/Instance;)[D",
                javabridge.get_env().make_double_array(class_probs), inst.jobject)
            return javabridge.get_env().get_double_array_elements(costs)