All PyTorch layers accept and expect batched inputs and don’t need a for loop or any other change.
nn.Linear in particular expects the input to have the shape [batch_size, *, in_features], where the * is a variable number of dimensions. The linear layer will be applied to each sample in these variable number of dimensions as if you would be using a loop over these dims.