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: Returns bytes object corresponding to referenced S3 object.
  
  Raises:
      ValueError: If the raw bytes payload is not formatted correctly.
docstr_tok: ["Returns","bytes","object","corresponding","to","referenced","S3","object",".","Raises",":","ValueError",":","If","the","raw","bytes","payload","is","not","formatted","correctly","."]
code: def get_bytes_payload_with_s3_references(
      self,
      payload_str: str,
  ) -> bytes:
      """Returns bytes object corresponding to referenced S3 object.
  
      Raises:
          ValueError: If the raw bytes payload is not formatted correctly.
      """
      s3_keys = re.compile(S3_BYTES_REGEX).findall(payload_str)
      if len(s3_keys) != 1:
          raise ValueError("Invalid bytes payload.")
  
      s3_key = s3_keys[0]
      serialized_s3_object = (
          JumpStartS3PayloadAccessor.get_object_cached(
              bucket=self.bucket,
              key=s3_key,
              region=self.region,
              s3_client=self.s3_client,
          )
      )
  
      return serialized_s3_object
  
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 2 for calling the PayloadSerializer obj's underlying member method code with example usage: obj.get_bytes_payload_with_s3_references(payload_str) and returns: serialized_s3_object