code: def on_after_run(self, end_script_globals):
      import torch
  
      # 1. Once the script has finished to execute,
      # we can collect its globals and access any objects.
      trainer = end_script_globals["cli"].trainer
      checkpoint_callback = trainer.checkpoint_callback
      lightning_module = trainer.lightning_module
  
      # 2. From the checkpoint_callback,
      # we are accessing the best model weights
      checkpoint = torch.load(checkpoint_callback.best_model_path)
  
      # 3. Load the best weights and torchscript the model.
      lightning_module.load_state_dict(checkpoint["state_dict"])
      lightning_module.to_torchscript(f"{self.name}.pt")
  
      # 4. Use lightning.app.storage.Pathto create a reference to the
      # torch scripted model. In the cloud with multiple machines,
      # by simply passing this reference to another work,
      # it triggers automatically a file transfer.
      self.best_model_path = Path(f"{self.name}.pt")
  
      # 5. Keep track of the metrics.
      self.best_model_score = float(
          checkpoint_callback.best_model_score
      )
  
imports: import io
  import os
  import subprocess
  import sys
  from copy import deepcopy
  from functools import partial
  from subprocess import Popen
  from typing import Dict, List, Optional
  from lightning import BuildConfig, CloudCompute, LightningApp, LightningFlow
  from lightning.app import structures
  from lightning.app.components import TracerPythonScript
  from lightning.app.frontend import StreamlitFrontend
  from lightning.app.storage.path import Path
  from lightning.app.utilities.state import AppState
label_desc: Use image node_id 3 for calling the PyTorchLightningGithubRepoRunner obj's underlying member method code with example usage: obj.on_after_run(end_script_globals) without return types