code: def _join_candidates(candidates: Iterable[glm.Candidate]):
      candidates = tuple(candidates)
  
      index = candidates[0].index  # These should all be the same.
  
      return glm.Candidate(
          index=index,
          content=_join_contents([c.content for c in candidates]),
          finish_reason=candidates[-1].finish_reason,
          safety_ratings=_join_safety_ratings_lists(
              [c.safety_ratings for c in candidates]
          ),
          citation_metadata=_join_citation_metadatas(
              [c.citation_metadata for c in candidates]
          ),
      )
  
imports: from __future__ import annotations
  import collections
  import contextlib
  import sys
  from collections.abc import Iterable, AsyncIterable
  import dataclasses
  import itertools
  import textwrap
  from typing import TypedDict, Union
  import google.protobuf.json_format
  import google.api_core.exceptions
  from google.ai import generativelanguage
  from google.generativeai import string_utils
label_desc: Use image node_id 5 for calling a global function with example usage: _join_candidates(candidates) and returns: glm