code: def test_load_or_create_when_exist(mock_create, mock_load):
      sagemaker_session = Session()
      trial_name = "trial_name"
      exp_name = "exp_name"
      exists_error = botocore.exceptions.ClientError(
          error_response={
              "Error": {
                  "Code": "ValidationException",
                  "Message": "Experiment with name (experiment-xyz) already exists.",
              }
          },
          operation_name="foo",
      )
      mock_create.side_effect = exists_error
      # The trial exists and experiment matches
      mock_load.return_value = _Trial(
          trial_name=trial_name,
          experiment_name=exp_name,
          sagemaker_session=sagemaker_session,
      )
      _Trial._load_or_create(
          trial_name=trial_name,
          experiment_name=exp_name,
          sagemaker_session=sagemaker_session,
      )
      mock_create.assert_called_once_with(
          trial_name=trial_name,
          experiment_name=exp_name,
          display_name=None,
          tags=None,
          sagemaker_session=sagemaker_session,
      )
      mock_load.assert_called_once_with(trial_name, sagemaker_session)
  
      # The trial exists but experiment does not match
      mock_load.return_value = _Trial(
          trial_name=trial_name,
          exp_name="another_exp_name",
          sagemaker_session=sagemaker_session,
      )
      with pytest.raises(ValueError) as err:
          _Trial._load_or_create(
              trial_name=trial_name,
              experiment_name=exp_name,
              sagemaker_session=sagemaker_session,
          )
      assert "The given experiment_name {} does not match that in the loaded trial".format(
          exp_name
      ) in str(
          err
      )
  
imports: from __future__ import absolute_import
  import botocore
  import pytest
  import datetime
  from unittest.mock import patch
  from sagemaker import Session
  from sagemaker.experiments._api_types import TrialSummary
  from sagemaker.experiments.trial import _Trial
  from sagemaker.experiments.trial_component import _TrialComponent
label_desc: Use image node_id 9 for calling a global function with example usage: test_load_or_create_when_exist(mock_create, mock_load) without return types