class_docstr: Tests for compatibility with TorchScript.
class_docstr_tok: ["Tests","for","compatibility","with","TorchScript","."]
docstr: Test basic saving of ScriptModule in file.
docstr_tok: ["Test","basic","saving","of","ScriptModule","in","file","."]
code: def test_save_scriptmodule_file(self):
      """
      Test basic saving of ScriptModule in file.
      """
      from package_a.test_module import ModWithTensor
  
      scripted_mod = torch.jit.script(
          ModWithTensor(torch.rand(1, 2, 3))
      )
  
      filename = self.temp()
      with PackageExporter(filename) as e:
          e.save_pickle("res", "mod.pkl", scripted_mod)
  
      importer = PackageImporter(filename)
      loaded_mod = importer.load_pickle("res", "mod.pkl")
      input = torch.rand(1, 2, 3)
      self.assertEqual(loaded_mod(input), scripted_mod(input))
  
imports: from io import BytesIO
  from textwrap import dedent
  from unittest import skipIf
  import torch
  from torch.package import PackageExporter, PackageImporter
  from torch.testing._internal.common_utils import IS_FBCODE, IS_SANDCASTLE, run_tests
label_desc: Use image node_id 7 for calling the TestPackageScript obj's underlying member method code with example usage: obj.test_save_scriptmodule_file() without return types