How to modify inherited class for additional parameters?
I am working on a problem statement related to python classes:
I have two classes:
class MCC(object):
    
    def __init__(self, problem_type, batch_size, dataset):
        
        self.problem_type = problem_type
        self.batch_size   = batch_size
        self.dataset      = dataset
        self.cls_weights  = weights_calculation()
        
    
    def weights_calculation(self):
        class_weights        = (1 - (self.dataset['labels'].value_counts().sort_index()/len(self.dataset))).values
        return class_weights

second class
from transformers import Trainer
class WeightedTrainer(Trainer):

    def compute_loss(self, model, inputs, return_outputs=False):
        outputs        = model(**inputs)
        logits         = outputs.get('logits')
        labels         = inputs.get('labels')
        loss_func      = nn.CrossEntropyLoss(weight = self.class_weights)
        loss           = loss_func(logits, labels)
        return (loss, outputs) if return_outputs else loss

In the second class, I have to pass weight in nn.CrossEntropyLoss as in code loss_func      = nn.CrossEntropyLoss(weight = self.class_weights)
I want to modify the inherited Trainer class to pass a new parameter custom_class_weight in  MCC class.
What I have tried:
class MCC(object):
    def __init__(self, problem_type, batch_size, dataset, model):
        
        self.problem_type    = problem_type
        self.batch_size      = batch_size
        self.dataset         = dataset
        self.model           = model
        
        self.cls_weights     = weights_calculation()
        self.WeightedTrainer = WeightedTrainer(self.cls_weights)
        self.trainer         = self.WeightedTrainer(self.model)



    def weights_calculation(self):
        class_weights        = (1 - (self.dataset['labels'].value_counts().sort_index()/len(self.dataset))).values
        return class_weights



class WeightedTrainer(Trainer):

    def __init__(self, custom_class_weight):
        self.custom_class_weight = custom_class_weight

    def compute_loss(self, model, inputs, return_outputs=False):
        outputs        = model(**inputs)
        logits         = outputs.get('logits')
        labels         = inputs.get('labels')
        loss_func      = nn.CrossEntropyLoss(weight = self.custom_class_weight)
        loss           = loss_func(logits, labels)
        return (loss, outputs) if return_outputs else loss

Which is disturbing the inherited's Trainer class properties and thus giving me an error:
TypeError: 'WeightedTrainer' object is not callable

I also tried:
class WeightedTrainer(Trainer):

    def __init__(self, custom_class_weight, **kwargs,):
        self.custom_class_weight = custom_class_weight
        super(WeightedTrainer, self).__init__(**kwargs)

    def compute_loss(self, model, inputs, return_outputs=False):
        outputs        = model(**inputs)
        logits         = outputs.get('logits')
        labels         = inputs.get('labels')
        loss_func      = nn.CrossEntropyLoss(weight = self.custom_class_weight)
        loss           = loss_func(logits, labels)
        return (loss, outputs) if return_outputs else loss

How to create a child class, using the Trainer class as a parent class and modify an inherited class while keeping all default properties of super class?

Thank you for @JMA valuable comment, Here is the fix.
I was calling self.WeightedTrainer which is not a callable object. Full working code:
class MCC(object):
    def __init__(self, problem_type, batch_size, dataset, model):
        
        self.problem_type    = problem_type
        self.batch_size      = batch_size
        self.dataset         = dataset
        self.model           = model
        
        self.cls_weights     = weights_calculation()
        self.custom_trainer  = WeightedTrainer
        self.trainer         = self.WeightedTrainer(self.model, custom_class_weight = self.cls_weights)


    def weights_calculation(self):
        class_weights        = (1 - (self.dataset['labels'].value_counts().sort_index()/len(self.dataset))).values
        return class_weights



class WeightedTrainer(Trainer):

    def __init__(self, custom_class_weight, **kwargs,):
        super().__init__(**kwargs)
        self.custom_class_weight = custom_class_weight

    def compute_loss(self, model, inputs, return_outputs=False):
        outputs        = model(**inputs)
        logits         = outputs.get('logits')
        labels         = inputs.get('labels')
        loss_func      = nn.CrossEntropyLoss(weight = self.custom_class_weight)
        loss           = loss_func(logits, labels)
        return (loss, outputs) if return_outputs else loss

