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 payload string or bytes that can be inputted to inference endpoint.
  
  Raises:
      ValueError: If the payload has an unrecognized type.
docstr_tok: ["Returns","payload","string","or","bytes","that","can","be","inputted","to","inference","endpoint",".","Raises",":","ValueError",":","If","the","payload","has","an","unrecognized","type","."]
code: def serialize(
      self, payload: JumpStartSerializablePayload
  ) -> Union[str, bytes]:
      """Returns payload string or bytes that can be inputted to inference endpoint.
  
      Raises:
          ValueError: If the payload has an unrecognized type.
      """
      content_type = MIMEType.from_suffixed_type(payload.content_type)
      body = payload.body
  
      if content_type in {
          MIMEType.JSON,
          MIMEType.LIST_TEXT,
          MIMEType.X_TEXT,
      }:
          body = self.embed_s3_references_in_json_payload(body)
      else:
          body = self.get_bytes_payload_with_s3_references(body)
  
      if isinstance(body, dict):
          body = json.dumps(body)
      elif not isinstance(body, str) and not isinstance(body, bytes):
          raise ValueError(
              f"Default payload '{body}' has unrecognized type: {type(body)}"
          )
  
      return 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 6 for calling the PayloadSerializer obj's underlying member method code with example usage: obj.serialize(payload) and returns: body