code: def apply(modifications, state):
          
          count = 0
          for a in modifications:
              if _debug:
                  assert a[0] in ('set', 'mv', 'map', 'rm')
                  logger.debug("processing rule: %s", str(a))
              if len(a) == 3:
                  operation, name, value = a
                  if operation == 'set':
                      state[name] = value
                      count += 1
                  elif operation == 'mv':
                      try:
                          arg = state.pop(name)
                          state[value] = arg
                          count += 1
                      except KeyError:
                          raise ClassVersionException("the previous version didn't "
                                                      "store an attribute named '{}'".format(a[1]))
                  elif operation == 'map':
                      func = value
                      if hasattr(func, '__func__'):
                          func = func.__func__
                      assert callable(func)
                      state[name] = func(state[name])
                      count += 1
              elif len(a) == 2:
                  operation, value = a
                  if operation == 'rm':
                      state.pop(value, None)
                      count += 1
                  elif operation == 'transform':
                      assert callable(value)
                      value(state)
                      count += 1
  
          assert count == len(modifications), 'was not able to process all modifications on state'
docs: applies modifications to given state
          Parameters
          ----------
          modifications: list of tuples
              created by this class.list method.
          state: dict
              state dictionary