code: def test_executor_map_with_run(
      sagemaker_session,
      dummy_container_without_error,
      cpu_instance_type,
  ):
      def square(x):
          with load_run() as run:
              result = x * x
              run.log_metric("x", result)
          return result
  
      exp_name = unique_name_from_base("my-test-exp")
      run_name = "my-test-run"
      tc_name = Run._generate_trial_component_name(
          experiment_name=exp_name, run_name=run_name
      )
  
      with cleanup_exp_resources(
          exp_names=[exp_name], sagemaker_session=sagemaker_session
      ):
          with Run(
              experiment_name=exp_name,
              run_name=run_name,
              sagemaker_session=sagemaker_session,
          ):
              with RemoteExecutor(
                  max_parallel_jobs=2,
                  role=ROLE,
                  image_uri=dummy_container_without_error,
                  instance_type=cpu_instance_type,
                  sagemaker_session=sagemaker_session,
                  keep_alive_period_in_seconds=30,
              ) as e:
                  results = e.map(square, [2, 4])
  
          assert len(results) == 2
          assert results[0] == 4
          assert results[1] == 16
  
          with RemoteExecutor(
              max_parallel_jobs=2,
              role=ROLE,
              image_uri=dummy_container_without_error,
              instance_type=cpu_instance_type,
              sagemaker_session=sagemaker_session,
              keep_alive_period_in_seconds=30,
          ) as e:
              with Run(
                  experiment_name=exp_name,
                  run_name=run_name,
                  sagemaker_session=sagemaker_session,
              ):
                  results = e.map(square, [6, 8])
  
          assert len(results) == 2
          assert results[0] == 36
          assert results[1] == 64
  
          tc = _TrialComponent.load(
              trial_component_name=tc_name,
              sagemaker_session=sagemaker_session,
          )
          assert len(tc.metrics) > 0
          for metric_summary in tc.metrics:
              if metric_summary.metric_name != "x":
                  continue
              assert metric_summary.max == 64
              assert metric_summary.min == 4
              assert metric_summary.avg == 30
  
file_path: sagemaker-python-sdk/tests/integ/sagemaker/remote_function/test_executor.py
imports: from __future__ import absolute_import
  import time
  import pytest
  from sagemaker.experiments.trial_component import _TrialComponent
  from sagemaker.remote_function import RemoteExecutor
  from sagemaker.remote_function.client import get_future, list_futures
  from sagemaker.experiments.run import Run, load_run
  from sagemaker.remote_function.core.serialization import CloudpickleSerializer
  from sagemaker.remote_function.errors import DeserializationError
  from sagemaker.s3 import S3Uploader
  from sagemaker.s3_utils import s3_path_join
  from tests.integ.sagemaker.experiments.helpers import cleanup_exp_resources
  from sagemaker.utils import unique_name_from_base
label_desc: Use image node_id 6 for calling a global function with example usage: test_executor_map_with_run(sagemaker_session, dummy_container_without_error, cpu_instance_type) and returns: result