code: def test_compile_and_deploy_model_with_neo(
      sagemaker_session,
      neo_pytorch_cpu_instance_type,
      neo_pytorch_latest_version,
      neo_pytorch_latest_py_version,
      neo_pytorch_target_device,
      neo_pytorch_compilation_job_name,
  ):
      endpoint_name = "test-neo-pytorch-deploy-model-{}".format(
          sagemaker_timestamp()
      )
  
      model_data = sagemaker_session.upload_data(path=NEO_MODEL)
      bucket = sagemaker_session.default_bucket()
      with timeout_and_delete_endpoint_by_name(
          endpoint_name, sagemaker_session
      ):
          model = PyTorchModel(
              model_data=model_data,
              predictor_cls=Predictor,
              role="SageMakerRole",
              entry_point=NEO_SCRIPT,
              source_dir=NEO_CODE_DIR,
              framework_version=neo_pytorch_latest_version,
              py_version=neo_pytorch_latest_py_version,
              sagemaker_session=sagemaker_session,
              env={"MMS_DEFAULT_RESPONSE_TIMEOUT": "500"},
          )
          data_shape = '{"input0":[1,3,224,224]}'
          compiled_model_path = "s3://{}/{}/output".format(
              bucket, neo_pytorch_compilation_job_name
          )
          compiled_model = model.compile(
              target_instance_family=neo_pytorch_target_device,
              input_shape=data_shape,
              job_name=neo_pytorch_compilation_job_name,
              role="SageMakerRole",
              framework="pytorch",
              framework_version=neo_pytorch_latest_version,
              output_path=compiled_model_path,
          )
  
          # Load names for ImageNet classes
          object_categories = {}
          with open(NEO_IMAGENET_CLASSES, "r") as f:
              for line in f:
                  if line.strip():
                      key, val = line.strip().split(":")
                      object_categories[key] = val
  
          with open(NEO_INFERENCE_IMAGE, "rb") as f:
              payload = f.read()
              payload = bytearray(payload)
  
          predictor = compiled_model.deploy(
              1,
              neo_pytorch_cpu_instance_type,
              endpoint_name=endpoint_name,
          )
          response = predictor.predict(payload)
          result = json.loads(response.decode())
  
          assert (
              "tiger cat" in object_categories[str(np.argmax(result))]
          )
          assert (
              compiled_model.framework_version
              == neo_pytorch_latest_version
          )
  
file_path: sagemaker-python-sdk/tests/integ/test_neo_pytorch.py
imports: from __future__ import absolute_import
  import numpy
  import os
  import json
  from sagemaker.pytorch.model import PyTorchModel
  from sagemaker.utils import sagemaker_timestamp
  from sagemaker.predictor import Predictor
  from tests.integ import DATA_DIR
  from tests.integ.timeout import timeout_and_delete_endpoint_by_name
label_desc: Use image node_id 1 for calling a global function with example usage: test_compile_and_deploy_model_with_neo(sagemaker_session, neo_pytorch_cpu_instance_type, neo_pytorch_latest_version, neo_pytorch_latest_py_version, neo_pytorch_target_device, neo_pytorch_compilation_job_name) without return types