hunk.code_window:         # Store values for stats function in model (tower), such that for
           # multi-GPU, we do not override them during the parallel loss phase.
           model.tower_stats["total_loss"] = total_loss
           model.tower_stats["mean_policy_loss"] = mean_policy_loss
           model.tower_stats["mean_vf_loss"] = mean_vf_loss
           model.tower_stats["vf_explained_var"] = explained_variance(
               train_batch[Postprocessing.VALUE_TARGETS], value_fn_out
           )
           model.tower_stats["mean_entropy"] = mean_entropy
  
hunk.labels: keep keep keep keep replace keep keep keep keep keep
hunk.after_edit:         model.tower_stats["mean_policy_loss"] = reduce_mean_valid(-surrogate_loss)
  
hunk.file_path: rllib/algorithms/ppo/ppo_torch_policy.py
hunk.type: replace
file: (serve-api)=
  # Ray Serve API
  
  (core-apis)=
  
  ## Core APIs
  
  ```{eval-rst}
  .. autofunction:: ray.serve.run
  ```
  
  ```{eval-rst}
  .. autofunction:: ray.serve.start
  ```
  
  ```{eval-rst}
  .. autofunction:: ray.serve.deployment
  ```
  
  ```{eval-rst}
  .. autofunction:: ray.serve.shutdown
  ```
  
  (deployment-api)=
  
  ## Deployment API
  
  ```{eval-rst}
  .. autoclass:: ray.serve.deployment.Deployment
      :members: deploy, delete, options, get_handle, bind
  ```
  
  (servehandle-api)=
  
  ## ServeHandle API
  
  ```{eval-rst}
  .. autoclass:: ray.serve.handle.RayServeHandle
      :members: remote, options
  ```
  
  ## Batching Requests
  
  ```{eval-rst}
  .. autofunction:: ray.serve.batch(max_batch_size=10, batch_wait_timeout_s=0.0)
  ```
  
  ## Serve CLI and REST API
  
  Check out the [CLI](serve-cli) and [REST API](serve-rest-api) for running, debugging, inspecting, and deploying Serve applications in production:
  
  ```{toctree}
  :maxdepth: 1
  :name: serve-non-python-api
  
  serve_cli
  rest_api
  ```
  
  ## Deployment Graph APIs
  
  ```{eval-rst}
  .. autofunction:: ray.serve.api.build
  ```
  
  % TODO(architkulkarni): This just compiles to "alias of Deployment(name=DAGDriver,version=None,route_prefix=/)"
  % in the docs, find out how to make Sphinx correctly autodocument this class.
  % ```{eval-rst}
  % .. autoclass:: ray.serve.drivers.DAGDriver
  %     :members: predict, predict_with_route
  % ```
  