code: def _build_result_view(view, form):
      if form.sample_ids:
          view = fov.make_optimized_select_view(view, form.sample_ids)
  
      if form.add_stages:
          for d in form.add_stages:
              stage = fos.ViewStage._from_dict(d)
              view = view.add_stage(stage)
  
      return view
  
imports: from dataclasses import asdict
  import strawberry
  import typing
  import eta.core.serial
  import fiftyone.constants
  import fiftyone.core.dataset
  import fiftyone.core.odm
  import fiftyone.core.session.events
  from fiftyone.core.session.events import StateUpdate
  from fiftyone.core.spaces import default_spaces, Space
  from fiftyone.core.state import build_color_scheme
  import fiftyone.core.stages
  import fiftyone.core.utils
  import fiftyone.core.view
  from fiftyone.server.aggregations import GroupElementFilter, SampleFilter
  from fiftyone.server.color import SetColorScheme
  from fiftyone.server.data import Info
  from fiftyone.server.events import get_state, dispatch_event
  from fiftyone.server.inputs import SelectedLabel
  from fiftyone.server.query import SidebarGroup, SavedView
  from fiftyone.server.scalars import BSON, BSONArray, JSON, JSONArray
  from fiftyone.server.view import get_view
label_desc: Use image node_id 1 for calling a global function with example usage: _build_result_view(view, form) and returns: view