Write a custom PyTorch autograd function or layer from scratch, explaining how the forward and backward passes are calculated.