code: def validate_invoked_inside_run_context(func):
      """A Decorator to force the decorated method called under Run context."""
  
      @wraps(func)
      def wrapper(*args, **kwargs):
          self_instance = args[0]
          if (
              not self_instance._inside_load_context
              and not self_instance._inside_init_context
          ):
              raise RuntimeError(
                  "This method should be called inside context of 'with' statement."
              )
          return func(*args, **kwargs)
  
      return wrapper
  
imports: from __future__ import absolute_import
  import logging
  import os
  import mimetypes
  import urllib
  from functools import wraps
  from typing import Optional
  from sagemaker import Session
  from sagemaker.apiutils import _utils
  from sagemaker.experiments._environment import _RunEnvironment, _EnvironmentType
  from sagemaker.experiments.trial_component import _TrialComponent
  from sagemaker.utilities.search_expression import Filter, Operator, SearchExpression
  from sagemaker.utils import retry_with_backoff
label_desc: Use image node_id 4 for calling a global function with example usage: validate_invoked_inside_run_context(func) and returns: wrapper, func