code: def json_serialize_obj_to_s3(
      obj: Any,
      json_key: str,
      sagemaker_session: Session,
      s3_uri: str,
      s3_kms_key: str = None,
  ):
      """Json serializes data object and uploads it to S3.
  
      If a function step's output is data referenced by other steps via JsonGet,
      its output should be json serialized and uploaded to S3.
  
      Args:
          obj: (Any) object to be serialized and persisted.
          json_key: (str) the json key pointing to function step output.
          sagemaker_session (sagemaker.session.Session):
              The underlying Boto3 session which AWS service calls are delegated to.
          s3_uri (str): S3 root uri to which resulting serialized artifacts will be uploaded.
          s3_kms_key (str): KMS key used to encrypt artifacts uploaded to S3.
      """
      json_serialized_result = {}
      try:
          to_dump = {json_key: obj, "Exception": None}
          json_serialized_result = json.dumps(to_dump)
      except TypeError as e:
          if "is not JSON serializable" in str(e):
              to_dump = {
                  json_key: None,
                  "Exception": f"The function return ({obj}) is not JSON serializable.",
              }
              json_serialized_result = json.dumps(to_dump)
  
      S3Uploader.upload_string_as_file_body(
          body=json_serialized_result,
          desired_s3_uri=s3_uri,
          sagemaker_session=sagemaker_session,
          kms_key=s3_kms_key,
      )
  
imports: from __future__ import absolute_import
  import dataclasses
  import json
  import io
  import sys
  import hmac
  import hashlib
  import pickle
  from typing import Any, Callable, Union
  import cloudpickle
  from tblib import pickling_support
  from sagemaker.remote_function.errors import ServiceError, SerializationError, DeserializationError
  from sagemaker.s3 import S3Downloader, S3Uploader
  from sagemaker.session import Session
  from ._custom_dispatch_table import dispatch_table
label_desc: Use image node_id 5 for calling a global function with example usage: json_serialize_obj_to_s3(obj, json_key, sagemaker_session, s3_uri, s3_kms_key) without return types