If you want to use the View in a sequential yes. You have to do this. Because the Sequential only passes the output of the previous layer.
For your Flatten layer, it seem to work fine no?
import torch
from torch import nn

class Flatten(nn.Module):
    def forward(self, input):
        '''
        Note that input.size(0) is usually the batch size.
        So what it does is that given any input with input.size(0) # of batches,
        will flatten to be 1 * nb_elements.
        '''
        batch_size = input.size(0)
        out = input.view(batch_size,-1)
        return out # (batch_size, *size)

print("2D input")
foo = torch.rand(10, 20)
print("Input size:")
print(foo.size())
bar = Flatten()(foo)
print("Output size:")
print(bar.size())

print("3D input")
foo = torch.rand(10, 20, 30)
print("Input size:")
print(foo.size())
bar = Flatten()(foo)
print("Output size:")
print(bar.size())

print("8D input")
foo = torch.rand(10, 2, 3, 4, 5, 6, 7, 8)
print("Input size:")
print(foo.size())
bar = Flatten()(foo)
print("Output size:")
print(bar.size())