code: def collect_to_container(
      backend: pipeline_backend.PipelineBackend,
      cols: Dict[str, Any],
      container_class: Type,
      stage_name: str,
  ):
      """Collects pCollections to one collection containing one element of
      a container class.
  
      It can be useful if you have different objects in pCollections,
      and you want to store all of them in one container object.
  
      Important: pCollections in col have to be keyed by the names that are
      exactly the same as the arguments' names in the container class constructor.
      Also, pCollections should contain exactly one element, otherwise behaviour
      is undefined.
  
      Example:
         @dataclass
         class Container:
             x: int
             y: str
             z: List[str]
  
         col_x = [2]
         col_y = ["str"]
         col_z = [["str1", "str2"]]
         container = collect({"x": col_x, "y": col_y, "z": col_z}, Container,
                             "stage name")
         # container will be equal to Container(x=2, y="str", z=["str1", "str2"]).
  
      Args:
        backend: backend to use to perform the computation.
        cols: one element collections to collect in the given container class
          keyed by argument names of the container class constructor.
        container_class: container where to put all the cols, has to be callable,
          i.e. container_class(**args_dict).
        stage_name: name of the stage.
  
      Returns:
        A collection that contains one instance of the container class.
      """
  
      def create_key_fn(key):
          # we cannot inline it due to lambda function closures capture
          # (https://stackoverflow.com/questions/2295290/what-do-lambda-function-closures-capture)
          return lambda _: key
  
      input_list = [
          key_by(
              backend,
              col,
              create_key_fn(key),
              f"{stage_name}: key input cols by their keys",
          )
          for key, col in cols.items()
      ]
      input_list = backend.flatten(
          input_list, f"{stage_name}: input cols to one PCollection"
      )
      input_list = backend.to_list(
          input_list, f"{stage_name}: inputs col to one list"
      )
      input_dict = backend.map(
          input_list,
          dict,
          f"{stage_name}: list of inputs to dictionary of inputs",
      )
      return backend.map(
          input_dict,
          lambda d: container_class(**d),
          f"{stage_name}: construct container class from inputs",
      )
  
imports: from typing import Type, Dict, Any, Callable, TypeVar, Iterable, List
  from pipeline_dp import pipeline_backend
label_desc: Use image node_id 3 for calling a global function with example usage: collect_to_container(backend, cols, container_class, stage_name) and returns: backend, function