code: def test_transformation_mark_and_transformed(self):
      _, traced = get_bert_model()
  
      class MarkLinears(ReversibleTransformation):
          def __init__(self, some_argument=None):
              self.some_argument = some_argument
  
          def transform(self, graph_module):
              for node in graph_module.graph.nodes:
                  if node.op == "call_module" and isinstance(
                      graph_module.get_submodule(node.target),
                      torch.nn.Linear,
                  ):
                      self.mark_as_transformed(node)
              return graph_module
  
          def reverse(self, graph_module):
              for node in graph_module.graph.nodes:
                  if node.op == "call_module" and isinstance(
                      graph_module.get_submodule(node.target),
                      torch.nn.Linear,
                  ):
                      self.mark_as_restored(node)
              return graph_module
  
      # Marked by one transform.
      t1 = MarkLinears()
      traced = t1(traced)
      for node in traced.graph.nodes:
          if node.op == "call_module" and isinstance(
              traced.get_submodule(node.target), torch.nn.Linear
          ):
              self.assertTrue(t1.transformed(node))
      # Not marked by another transform.
      t2 = MarkLinears(some_argument="test")
      for node in traced.graph.nodes:
          if node.op == "call_module" and isinstance(
              traced.get_submodule(node.target), torch.nn.Linear
          ):
              self.assertFalse(t2.transformed(node))
      # And now marked by it.
      traced = t2(traced)
      for node in traced.graph.nodes:
          if node.op == "call_module" and isinstance(
              traced.get_submodule(node.target), torch.nn.Linear
          ):
              self.assertTrue(t2.transformed(node))
      # Reversed first transform, nodes should not be marked as transformed anymore.
      traced = t1(traced, reverse=True)
      for node in traced.graph.nodes:
          if node.op == "call_module" and isinstance(
              traced.get_submodule(node.target), torch.nn.Linear
          ):
              self.assertFalse(t1.transformed(node))
  
imports: import operator
  import unittest
  import torch
  from parameterized import parameterized
  from transformers import AutoModel, AutoModelForImageClassification, AutoTokenizer, BertModel
  from transformers.models.bert.modeling_bert import BertSelfAttention
  from transformers.utils.fx import symbolic_trace
  from optimum.fx.optimization import ChangeTrueDivToMulByInverse, FuseBatchNorm1dInLinear, FuseBatchNorm2dInConv2d, FuseBiasInLinear, MergeLinears, ReversibleTransformation, Transformation, compose
  from optimum.fx.utils import are_fx_features_available
label_desc: Use image node_id 10 for calling the TransformationTester obj's underlying member method code with example usage: obj.test_transformation_mark_and_transformed() and returns: graph_module, graph_module