How would you write a custom PyTorch autograd function to simulate hardware-specific constraints during the forward pass for TETRAMEM?