code: def create_attachment(payload):
      """
      Create a simple url-based attachment.
      """
      # TODO support data-based attachments?
      assert payload["type"] in [
          "image",
          "video",
          "file",
          "audio",
      ], "unsupported attachment type"
      assert (
          "url" in payload or "attachment_id" in payload
      ), "unsupported attachment method: must contain url or attachment_id"
      if "url" in payload:
          return {
              "type": payload["type"],
              "payload": {"url": payload["url"]},
          }
      elif "attachment_id" in payload:
          return {
              "type": payload["type"],
              "payload": {"attachment_id": payload["attachment_id"]},
          }
  
file_path: ParlAI/parlai/chat_service/services/messenger/message_sender.py
imports: import json
  import logging
  import requests
  import parlai.chat_service.utils.logging
label_desc: Use image node_id 1 for calling a global function with example usage: create_attachment(payload) and returns: dict, dict