class_docstr: Tests for compatibility with TorchScript.
class_docstr_tok: ["Tests","for","compatibility","with","TorchScript","."]
docstr: Test saving of single ScriptModule shared by multiple
  eager modules (ScriptModule should be saved just once
  even though is contained in multiple pickles).
docstr_tok: ["Test","saving","of","single","ScriptModule","shared","by","multiple","eager","modules","(","ScriptModule","should","be","saved","just","once","even","though","is","contained","in","multiple","pickles",")","."]
code: def test_save_eager_mods_sharing_scriptmodule(self):
      """
      Test saving of single ScriptModule shared by multiple
      eager modules (ScriptModule should be saved just once
      even though is contained in multiple pickles).
      """
      from package_a.test_module import ModWithSubmod, SimpleTest
  
      scripted_mod = torch.jit.script(SimpleTest())
  
      mod1 = ModWithSubmod(scripted_mod)
      mod2 = ModWithSubmod(scripted_mod)
  
      buffer = BytesIO()
      with PackageExporter(buffer) as e:
          e.intern("**")
          e.save_pickle("res", "mod1.pkl", mod1)
          e.save_pickle("res", "mod2.pkl", mod2)
  
      buffer.seek(0)
      importer = PackageImporter(buffer)
      file_structure = importer.file_structure()
      self.assertTrue(file_structure.has_file(".data/ts_code/0"))
      self.assertFalse(file_structure.has_file(".data/ts_code/1"))
  
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 15 for calling the TestPackageScript obj's underlying member method code with example usage: obj.test_save_eager_mods_sharing_scriptmodule() without return types