code: def _hooks_apply_before_serialize(
          hooks,  # type: Optional[Hooks]
          state,  # type: _ProcessorState
          value  # type: Any
  ):
      # type: (...) -> Any
      
      if hooks and hooks.before_serialize:
          return hooks.before_serialize(ProcessorStateView(state), value)
  
      return value
docs: Apply the before serialize hook.