code: def scale(self, replicas: int, metrics: dict) -> int:
      pending_requests = metrics["pending_requests"]
      active_or_pending_works = replicas + metrics["pending_works"]
  
      if active_or_pending_works == 0:
          return 1 if pending_requests > 0 else 0
  
      pending_requests_per_running_or_pending_work = (
          pending_requests / active_or_pending_works
      )
  
      # scale out if the number of pending requests exceeds max batch size.
      max_requests_per_work = self.max_batch_size
      if (
          pending_requests_per_running_or_pending_work
          >= max_requests_per_work
      ):
          return replicas + 1
  
      # scale in if the number of pending requests is below 25% of max_requests_per_work
      min_requests_per_work = max_requests_per_work * 0.25
      if (
          pending_requests_per_running_or_pending_work
          < min_requests_per_work
      ):
          return replicas - 1
  
      return replicas
  
file_path: pytorch-lightning/examples/app/server_with_auto_scaler/app.py
imports: from typing import List
  import torch
  import torchvision
  from lightning.app import CloudCompute, LightningApp
  from pydantic import BaseModel
label_desc: Use image node_id 1 for calling the MyAutoScaler obj's underlying member method code with example usage: obj.scale(replicas, metrics) and returns: replicas, unknown, unknown, unknown