examples/research_projects/bertabs/modeling_bertabs.py/TransformerDecoderState/detach
class TransformerDecoderState:    def detach(self):
        if self.previous_input is not None:
            self.previous_input = self.previous_input.detach()
        if self.previous_layer_inputs is not None:
            self.previous_layer_inputs = self.previous_layer_inputs.detach()
        self.src = self.src.detach()