class_docstr: Tests for compatibility with TorchScript.
class_docstr_tok: ["Tests","for","compatibility","with","TorchScript","."]
docstr: Packaging an interface class should work correctly.
docstr_tok: ["Packaging","an","interface","class","should","work","correctly","."]
code: def test_package_interface(self):
      """Packaging an interface class should work correctly."""
  
      import package_a.fake_interface as fake
  
      uses_interface = fake.UsesInterface()
      scripted = torch.jit.script(uses_interface)
      scripted.proxy_mod = torch.jit.script(fake.NewModule())
  
      buffer = BytesIO()
      with PackageExporter(buffer) as pe:
          pe.intern("**")
          pe.save_pickle("model", "model.pkl", uses_interface)
      buffer.seek(0)
  
      package_importer = PackageImporter(buffer)
      loaded = package_importer.load_pickle("model", "model.pkl")
  
      scripted_loaded = torch.jit.script(loaded)
      scripted_loaded.proxy_mod = torch.jit.script(fake.NewModule())
  
      input = torch.tensor(1)
  
      self.assertEqual(scripted(input), scripted_loaded(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 1 for calling the TestPackageScript obj's underlying member method code with example usage: obj.test_package_interface() without return types