code: def _check_jit_scriptable(
      nn_module, args, unwrapper=None, eager_out=None
  ):
      """Check that a nn.Module's results in TorchScript match eager and that it can be exported"""
  
      def get_export_import_copy(m):
          """Save and load a TorchScript model"""
          with TemporaryDirectory() as dir:
              path = os.path.join(dir, "script.pt")
              m.save(path)
              imported = torch.jit.load(path)
          return imported
  
      sm = torch.jit.script(nn_module)
      sm.eval()
  
      if eager_out is None:
          with torch.no_grad(), freeze_rng_state():
              eager_out = nn_module(*args)
  
      with torch.no_grad(), freeze_rng_state():
          script_out = sm(*args)
          if unwrapper:
              script_out = unwrapper(script_out)
  
      torch.testing.assert_close(
          eager_out, script_out, atol=1e-4, rtol=1e-4
      )
  
      m_import = get_export_import_copy(sm)
      with torch.no_grad(), freeze_rng_state():
          imported_script_out = m_import(*args)
          if unwrapper:
              imported_script_out = unwrapper(imported_script_out)
  
      torch.testing.assert_close(
          script_out, imported_script_out, atol=3e-4, rtol=3e-4
      )
  
imports: import contextlib
  import functools
  import operator
  import os
  import pkgutil
  import platform
  import sys
  import warnings
  from collections import OrderedDict
  from tempfile import TemporaryDirectory
  from typing import Any
  import pytest
  import torch
  import torch.fx
  import torch.nn
  from _utils_internal import get_relative_path
  from common_utils import cpu_and_cuda, freeze_rng_state, map_nested_tensor_object, needs_cuda, set_rng_seed
  from PIL import Image
  from torchvision import models, transforms
  from torchvision.models import get_model_builder, list_models
label_desc: Use image node_id 6 for calling a global function with example usage: _check_jit_scriptable(nn_module, args, unwrapper, eager_out) and returns: imported