Could you post an executable code snippet to reproduce this issue?
Using the forward method and removing undefined parts of the code does not result in a memory leak:
class MyModel(nn.Module):
    def __init__(self):
        super(MyModel, self).__init__()
        self.shared_gen_linear = nn.Linear(10, 10)
        
    def forward(self, noise, elem_class):
        
        process = psutil.Process(os.getpid())
        print("Memory 1.1: ", process.memory_info().rss, "bytes", flush=True)
        
        in_vector = torch.cat((noise, elem_class), dim=-1) 
        
        process = psutil.Process(os.getpid())
        print("Memory 1.2: ", process.memory_info().rss, "bytes", flush=True)
        
        in_vector = self.shared_gen_linear(in_vector)
        
        process = psutil.Process(os.getpid())
        print("Memory 1.3: ", process.memory_info().rss, "bytes", flush=True)
        
        in_vector = F.relu(in_vector)           #   batch_size x (2*standard_dim)
        
        process = psutil.Process(os.getpid())
        print("Memory 1.4: ", process.memory_info().rss, "bytes", flush=True)
        
        feats = in_vector[:, :5]
        feats2 = in_vector[:, 5:]
        
        process = psutil.Process(os.getpid())
        print("Memory 1.4: ", process.memory_info().rss, "bytes", flush=True)
        
        return feats, feats2


model = MyModel()
model(torch.randn(1, 5), torch.randn(1, 5))
>Memory 1.1:  247803904 bytes
Memory 1.2:  247803904 bytes
Memory 1.3:  247803904 bytes
Memory 1.4:  247803904 bytes
Memory 1.4:  247803904 bytes