In custom modules the “first layer” annotation might be misleading as seen in this example:
class MyModel(nn.Module):
    def __init__(self):
        super(MyModel, self).__init__()
        self.conv2 = nn.Conv2d(3, 3, 3, 1, 1)
        self.conv1 = nn.Conv2d(3, 3, 3, 1, 1)
        
    def forward(self, x):
        x = F.relu(self.conv1(x))
        x = self.conv2(x)
        return x

model = MyModel()
print(model)
print(next(model.named_children()))

model.named_children() as well as the print(model) statement will return conv2 as the “first” layer, but in the end the usage of the modules in the forward defines the order of execution.
Anyway, next(model.named_children()) might work for you.
Note that finding the “first layer” also depends what you mean by layer, as nn.Modules might themselves contain more modules as seen here:
class MyModel(nn.Module):
    def __init__(self):
        super(MyModel, self).__init__()
        self.conv2 = models.resnet18()
        self.conv1 = nn.Conv2d(3, 3, 3, 1, 1)
        
    def forward(self, x):
        x = F.relu(self.conv1(x))
        x = self.conv2(x)
        return x

model = MyModel()
print(model)
print(next(model.named_children()))