code: def _assemble_alert_publisher_for_output(
      alert, output_service_name, descriptor
  ):
      """Gathers all requested publishers on the alert and returns them as a single Publisher
  
      Note: The alert.publishers field cannot contain references to actual publisher functions
      or classes, because this field is pulled from Dynamo. It is always going to be a JSON-formatted
      object.
  
      Args:
          alert (Alert): The alert that is pulled from DynamoDB
          output_service_name (str): The __service__ name of the OutputDispatcher
          descriptor (str): The descriptor of the Output
  
      Returns:
          AlertPublisher
      """
  
      alert_publishers = alert.publishers
      publisher_names = []
      if isinstance(alert_publishers, str):
          # Case 1: The publisher is a single string.
          #   apply this single publisher to all outputs + descriptors
          publisher_names.append(alert_publishers)
      elif isinstance(alert_publishers, list):
          # Case 2: The publisher is an array of strings.
          #   apply all publishers to all outputs + descriptors
          publisher_names += alert_publishers
      elif isinstance(alert_publishers, dict):
          # Case 3: The publisher is a dict mapping output strings -> strings or list of strings
          #   apply only publishers under the correct output key. We look under 2 keys:
          #   one key that applies publishers to all outputs for a specific output type, and
          #   another key that applies publishers only to outputs of the type AND matching
          #   descriptor.
  
          # Order is important here; we load the output-generic publishers first
          if (
              output_service_name
              and output_service_name in alert_publishers
          ):
              publisher_name_or_names = alert_publishers[
                  output_service_name
              ]
              if isinstance(publisher_name_or_names, list):
                  publisher_names = (
                      publisher_names + publisher_name_or_names
                  )
              else:
                  publisher_names.append(publisher_name_or_names)
  
          # Then load output+descriptor-specific publishers second
          described_output_name = "{}:{}".format(
              output_service_name, descriptor
          )
          if described_output_name in alert_publishers:
              publisher_name_or_names = alert_publishers[
                  described_output_name
              ]
              if isinstance(publisher_name_or_names, list):
                  publisher_names += publisher_name_or_names
              else:
                  publisher_names.append(publisher_name_or_names)
  
      return AlertPublisherRepository.create_composite_publisher(
          publisher_names
      )
  
imports: from streamalert.shared.publisher import AlertPublisherRepository, PublisherAssemblyError
label_desc: Use image node_id 3 for calling a global function with example usage: _assemble_alert_publisher_for_output(alert, output_service_name, descriptor) and returns: AlertPublisherRepository