hunk.code_window:     if state:
           max_seq_len = torch.max(train_batch["seq_lens"])
           mask = sequence_mask(train_batch["seq_lens"], max_seq_len)
           mask = torch.reshape(mask, [-1])
       else:
           mask = torch.ones_like(
               train_batch[Postprocessing.ADVANTAGES], dtype=torch.bool)
       policy.loss_obj = PPOLoss(
           dist_class,
           model,
           train_batch[Postprocessing.VALUE_TARGETS],
  
hunk.labels: keep keep keep keep replace replace replace keep keep keep keep keep
hunk.file_path: rllib/agents/ppo/ppo_torch_policy.py
hunk.type: replace
file: """
  Example service that prints out http context.
  """
  
  import time
  
  import requests
  
  from ray import serve
  from ray.serve.utils import pformat_color_json
  
  
  def echo(flask_request):
      return "hello " + flask_request.args.get("name", "serve!")
  
  
  serve.init(blocking=True)
  
  serve.create_endpoint("my_endpoint", "/echo", blocking=True)
  serve.create_backend(echo, "echo:v1")
  serve.link("my_endpoint", "echo:v1")
  
  while True:
      resp = requests.get("http://127.0.0.1:8000/echo").json()
      print(pformat_color_json(resp))
  
      print("...Sleeping for 2 seconds...")
      time.sleep(2)
  