class_docstr: Utility class for serializing payloads associated with JumpStart models.
  
  Many JumpStart models embed byte-streams into payloads corresponding to images, sounds,
  and other content types which require downloading from S3.
docstr: Performs base 64 encoding of payloads embedded in a payload.
  
  This is required so that byte-valued payloads can be transmitted efficiently
  as a utf-8 encoded string.
docstr_tok: ["Performs","base","64","encoding","of","payloads","embedded","in","a","payload",".","This","is","required","so","that","byte-valued","payloads","can","be","transmitted","efficiently","as","a","utf-8","encoded","string","."]
code: def _embed_s3_b64_references_in_str_payload(
      self,
      payload_body: str,
  ) -> str:
      """Performs base 64 encoding of payloads embedded in a payload.
  
      This is required so that byte-valued payloads can be transmitted efficiently
      as a utf-8 encoded string.
      """
  
      s3_keys = re.compile(S3_B64_STR_REGEX).findall(payload_body)
      for s3_key in s3_keys:
          b64_encoded_string = base64.b64encode(
              bytearray(
                  JumpStartS3PayloadAccessor.get_object_cached(
                      bucket=self.bucket,
                      key=s3_key,
                      region=self.region,
                      s3_client=self.s3_client,
                  )
              )
          ).decode()
          payload_body = payload_body.replace(
              f"$s3_b64<{s3_key}>", b64_encoded_string
          )
      return payload_body
  
imports: from __future__ import absolute_import
  import base64
  import json
  from typing import Any, Dict, List, Optional, Union
  import re
  import boto3
  from sagemaker.jumpstart.accessors import JumpStartS3PayloadAccessor
  from sagemaker.jumpstart.artifacts.payloads import _retrieve_example_payloads
  from sagemaker.jumpstart.constants import DEFAULT_JUMPSTART_SAGEMAKER_SESSION, JUMPSTART_DEFAULT_REGION_NAME
  from sagemaker.jumpstart.enums import MIMEType
  from sagemaker.jumpstart.types import JumpStartSerializablePayload
  from sagemaker.jumpstart.utils import get_jumpstart_content_bucket
  from sagemaker.session import Session
label_desc: Use image node_id 4 for calling the PayloadSerializer obj's underlying member method code with example usage: obj._embed_s3_b64_references_in_str_payload(payload_body) and returns: payload_body