Question about deepcopy a model

Hi everyone,

I have kind of an unique question about deepcopy a model. Currently, I’m doing a project about Neural Architecture Search to find a new recurrent cell (like LSTM). Suppose I have 3 modules A, B and C, with A and B both use C in their forward. After that, both A and B will be used in a new recurrent cell

class A(nn.Module):
    def __init__(self, C):
        # other modules
        self.C = C

    def forward(self, x):
        # other modules
        output = self.C(x)

# similar to B

class RecurrentCell(nn.Module):
    def __init__(self, A, B):
        self.A = A
        self.B = B

    def forward(self, x_a, x_b):
        x_a = self.A(x_a)
        x_b = self.B(x_b)
        return x_a, x_b

Because I want my new recurrent cell to behave like Pytorch RNN/LSTM module, I use deepcopy on A and B to copy the RecurrentCell to use in other layers. My question is that if I use deepcopy like that, will A and B still share the same copy of C (i.e A.C and B.C are the same object)?

Thanks for your help.