code: def test_build_happy_path_with_sagemaker_endpoint_mode_and_1p_dlc_as_byoc(
      self,
      mock_path_exists,
      mock_sdk_model,
      mock_sageMakerEndpointMode,
      mock_serveSettings,
      mock_detect_container,
      mock_save_pkl,
      mock_prepare_for_torchserve,
      mock_detect_fw_version,
  ):
      # setup mocks
      mock_detect_container.side_effect = (
          lambda model, region, instance_type: mock_1p_dlc_image_uri
          if model == mock_fw_model
          and region == mock_session.boto_region_name
          and instance_type == "ml.c5.xlarge"
          else None
      )
  
      mock_detect_fw_version.return_value = framework, version
  
      mock_prepare_for_torchserve.side_effect = (
          lambda model_path, shared_libs, dependencies, session, image_uri, inference_spec: mock_secret_key
          if model_path == MODEL_PATH
          and shared_libs == []
          and dependencies == {"auto": False}
          and session == session
          and image_uri == mock_1p_dlc_image_uri
          and inference_spec is None
          else None
      )
  
      # Mock _ServeSettings
      mock_setting_object = mock_serveSettings.return_value
      mock_setting_object.role_arn = mock_role_arn
      mock_setting_object.s3_model_data_url = mock_s3_model_data_url
  
      mock_path_exists.side_effect = (
          lambda path: True if path == "test_path" else False
      )
  
      mock_mode = Mock()
      mock_sageMakerEndpointMode.side_effect = (
          lambda inference_spec, model_server: mock_mode
          if inference_spec is None
          and model_server == ModelServer.TORCHSERVE
          else None
      )
      mock_mode.prepare.side_effect = (
          lambda model_path, secret_key, s3_model_data_url, sagemaker_session, image_uri, jumpstart: (
              model_data,
              ENV_VAR_PAIR,
          )
          if model_path == MODEL_PATH
          and secret_key == mock_secret_key
          and s3_model_data_url == mock_s3_model_data_url
          and sagemaker_session == mock_session
          and image_uri == mock_1p_dlc_image_uri
          else None
      )
  
      mock_model_obj = Mock()
      mock_sdk_model.side_effect = (
          lambda image_uri, model_data, role, env, sagemaker_session, predictor_cls: mock_model_obj
          if image_uri == mock_1p_dlc_image_uri
          and model_data == model_data
          and role == mock_role_arn
          and env == ENV_VARS
          and sagemaker_session == mock_session
          else None
      )
  
      mock_session.sagemaker_client._user_agent_creator.to_string = (
          lambda: "sample agent"
      )
  
      # run
      builder = ModelBuilder(
          model_path=MODEL_PATH,
          schema_builder=schema_builder,
          model=mock_fw_model,
          model_server=ModelServer.TORCHSERVE,
          image_uri=mock_1p_dlc_image_uri,
      )
      build_result = builder.build(sagemaker_session=mock_session)
  
      # assert auto-detection was skipped
      mock_detect_container.assert_not_called()
  
      # assert model returned by builder is expected
      self.assertEqual(mock_model_obj, build_result)
      self.assertEqual(build_result.mode, Mode.SAGEMAKER_ENDPOINT)
      self.assertEqual(
          build_result.modes, {str(Mode.SAGEMAKER_ENDPOINT): mock_mode}
      )
      self.assertEqual(build_result.serve_settings, mock_setting_object)
  
imports: from __future__ import absolute_import
  from unittest.mock import MagicMock, patch, Mock
  import unittest
  from pathlib import Path
  from sagemaker.serve.builder.model_builder import ModelBuilder
  from sagemaker.serve.mode.function_pointers import Mode
  from sagemaker.serve.utils.types import ModelServer
label_desc: Use image node_id 7 for calling the TestModelBuilder obj's underlying member method code with example usage: obj.test_build_happy_path_with_sagemaker_endpoint_mode_and_1p_dlc_as_byoc(mock_path_exists, mock_sdk_model, mock_sageMakerEndpointMode, mock_serveSettings, mock_detect_container, mock_save_pkl, mock_prepare_for_torchserve, mock_detect_fw_version) without return types