I did it like this:
import torch
import torch.nn as nn

def pdf_cauchy_distribution(tensor):
    '''
    this fuction takes the output from neural netwrok's layer and implements a 
    kernal function which acts as an activation function.
    
    input:
    tensor: output of neural network's layer computation (w*x + b)
    
    output:
    also a tensor which after going to pdf cauchy distribution fucntion
    which is f(x) = 1/(1+x^2)
    '''
    
    return (1 / (1 + torch.mul(tensor, tensor)))

class cauchy_activation(nn.Module):
    def __init__(self):
        super(cauchy_activation, self).__init__()
        
    def activation(self, inp):
        return pdf_cauchy_distribution(self.inp)

and in model file:
class Resnet18(BaseModel):
    def __init__(self, classes=10):
        super(Resnet18, self).__init__()
        par = argparse.ArgumentParser(description='Model_resnet18')
        par.add_argument('-c', '--config', default = 'config.json', type=str, help = 'config file path (default: None)')
        args = par.parse_args()
        config = json.load(open(args.config))
        
        self.resnet = models.resnet18(pretrained = False)
        num_ftrs = self.resnet.fc.in_features
        self.resnet.fc = nn.Linear(num_ftrs, classes, bias=config['arch']['last_layer_bias'])
        self.resnet.layer4[1].relu = cauchy_activation.activation
        '''
        ct = 0
        for child in self.resnet.children():
            #print("child ", ct, ": \n", child)
            for param in child.parameters():
                if(ct != 9):
                    param.requires_grad = False 
                #elif(ct != 7):
                    #param.requires_grad = False
            ct += 1
        #exit
        '''
        #self.resnet.lay
    def forward(self, x_input):
        output = self.resnet(x_input)
        return output 

still it is giving same error:
TypeError: cannot assign 'model.activation.cauchy_activation.activation' as child module 'relu' (torch.nn.Module or None expected)