code: def _get_payload(
      msg: email.message.Message, source: Union[bytes, str]
  ) -> str:
      """Get the body of the message."""
      # If our source is a str, then our caller has managed encodings for us,
      # and we don't need to deal with it.
      if isinstance(source, str):
          payload: str = msg.get_payload()
          return payload
      # If our source is a bytes, then we're managing the encoding and we need
      # to deal with it.
      else:
          bpayload: bytes = msg.get_payload(decode=True)
          try:
              return bpayload.decode("utf8", "strict")
          except UnicodeDecodeError:
              raise ValueError("payload in an invalid encoding")
  
imports: import email.feedparser
  import email.header
  import email.message
  import email.parser
  import email.policy
  import sys
  import typing
  from typing import Any, Callable, Dict, Generic, List, Optional, Tuple, Type, Union, cast
  from .None import requirements, specifiers, utils, version
label_desc: Use image node_id 3 for calling a global function with example usage: _get_payload(msg, source) and returns: payload, bpayload