class_docstr: Tests for access APIs for packaged resources.
docstr: Tests that packaged code can used importlib.resources.path.
code: def test_resource_access_by_path(self):
      """
      Tests that packaged code can used importlib.resources.path.
      """
      buffer = BytesIO()
      with PackageExporter(buffer) as he:
          he.save_binary("string_module", "my_string", b"my string")
          src = dedent(
              """\
                  import importlib.resources
                  import string_module
  
                  with importlib.resources.path(string_module, 'my_string') as path:
                      with open(path, mode='r', encoding='utf-8') as f:
                          s = f.read()
                  """
          )
          he.save_source_string("main", src, is_package=True)
      buffer.seek(0)
      hi = PackageImporter(buffer)
      m = hi.import_module("main")
      self.assertEqual(m.s, "my string")
  
file_path: pytorch/test/package/test_resources.py
imports: from io import BytesIO
  from sys import version_info
  from textwrap import dedent
  from unittest import skipIf
  from torch.package import PackageExporter, PackageImporter
  from torch.testing._internal.common_utils import run_tests
label_desc: Use image node_id 4 for calling the TestResources obj's underlying member method code with example usage: obj.test_resource_access_by_path() without return types