code: def _post_sync(self, data):
      dataset_name = data["datasetName"]
      brain_key = data["brainKey"]
      stages = data["view"]
      filters = data.get("filters", None)
      label_field = data["labelField"]
      slices = data["slices"]
      dataset = fosu.load_and_cache_dataset(dataset_name)
  
      try:
          results = dataset.load_brain_results(brain_key)
          assert results is not None
      except:
          msg = (
              "Failed to load results for brain run with key '%s'. Try "
              "regenerating the results"
          ) % brain_key
          return {"error": msg}
  
      view = fosv.get_view(
          dataset_name,
          stages=stages,
          filters=filters,
          sample_filter=get_sample_filter(slices),
      )
  
      is_patches_view = view._is_patches
  
      patches_field = results.config.patches_field
      is_patches_plot = patches_field is not None
  
      # Determines which points from `results` are in `view`, which are the
      # only points we want to display in the embeddings plot
      if view.view() != results.view.view():
          results.use_view(view, allow_missing=True)
  
      # The total number of embeddings in `results`
      index_size = results.total_index_size
  
      # The number of embeddings in `results` that exist in `view`. Any
      # operations that we do with `results` can only work with this data
      available_count = results.index_size
  
      # The number of samples/patches in `view` that `results` doesn't have
      # embeddings for
      missing_count = results.missing_size
  
      points = results._curr_points
      if is_patches_plot:
          ids = results._curr_label_ids
          sample_ids = results._curr_sample_ids
      else:
          ids = results._curr_sample_ids
          sample_ids = itertools.repeat(None)
  
      # Color by data
      if label_field:
          if is_patches_view and not is_patches_plot:
              # Must use the root dataset in order to retrieve colors for the
              # plot, which is linked to samples, not patches
              view = view._root_dataset
  
          if is_patches_view and is_patches_plot:
              # `label_field` is always provided with respect to root
              # dataset, so we must translate for patches views
              _, root = dataset._get_label_field_path(patches_field)
              leaf = label_field[len(root) + 1 :]
              _, label_field = view._get_label_field_path(
                  patches_field, leaf
              )
  
          labels = view._get_values_by_id(
              label_field, ids, link_field=patches_field
          )
  
          field = view.get_field(label_field)
  
          if isinstance(field, fof.ListField):
              labels = [l[0] if l else None for l in labels]
              field = field.field
  
          if isinstance(field, fof.FloatField):
              style = "continuous"
          else:
              if len(set(labels)) <= MAX_CATEGORIES:
                  style = "categorical"
              else:
                  style = "continuous"
      else:
          labels = itertools.repeat(None)
          style = "uncolored"
  
      selected = itertools.repeat(True)
  
      traces = {}
      for data in zip(points, ids, sample_ids, labels, selected):
          _add_to_trace(traces, style, *data)
  
      return {
          "traces": traces,
          "style": style,
          "index_size": index_size,
          "available_count": available_count,
          "missing_count": missing_count,
          "patches_field": patches_field,
      }
  
imports: import itertools
  from starlette.endpoints import HTTPEndpoint
  from starlette.requests import Request
  import fiftyone.core.fields
  import fiftyone.core.stages
  from fiftyone.core.utils import run_sync_task
  from fiftyone.server.decorators import route
  import fiftyone.server.utils
  import fiftyone.server.view
  from fiftyone.server.filters import GroupElementFilter, SampleFilter
label_desc: Use image node_id 1 for calling the OnPlotLoad obj's underlying member method code with example usage: obj._post_sync(data) and returns: dict, dict