class_docstr: Selection display base class that represents selections by overlaying
  colored subsets on top of the original element in an Overlay container.
class_docstr_tok: ["Selection","display","base","class","that","represents","selections","by","overlaying","colored","subsets","on","top","of","the","original","element","in","an","Overlay","container","."]
code: def build_selection(
      self,
      selection_streams,
      hvobj,
      operations,
      region_stream=None,
      cache=None,
  ):
      from .element import Histogram
  
      num_layers = len(selection_streams.style_stream.colors)
      if not num_layers:
          return Overlay()
  
      layers = []
      for layer_number in range(num_layers):
          streams = [selection_streams.exprs_stream]
          obj = hvobj.clone(link=False) if layer_number == 1 else hvobj
          cmap_stream = selection_streams.cmap_streams[layer_number]
          layer = obj.apply(
              self._build_layer_callback,
              streams=[cmap_stream] + streams,
              layer_number=layer_number,
              cache=cache,
              per_element=True,
          )
          layers.append(layer)
  
      for layer_number in range(num_layers):
          layer = layers[layer_number]
          cmap_stream = selection_streams.cmap_streams[layer_number]
          streams = [selection_streams.style_stream, cmap_stream]
          layer = layer.apply(
              self._apply_style_callback,
              layer_number=layer_number,
              streams=streams,
              per_element=True,
          )
          layers[layer_number] = layer
  
      # Build region layer
      if region_stream is not None and self.supports_region:
  
          def update_region(element, region_element, colors, **kwargs):
              unselected_color = colors[0]
              if region_element is None:
                  region_element = element._empty_region()
              return self._style_region_element(
                  region_element, unselected_color
              )
  
          streams = [region_stream, selection_streams.style_stream]
          region = hvobj.clone(link=False).apply(
              update_region, streams, link_dataset=False
          )
  
          eltype = (
              hvobj.type
              if isinstance(hvobj, DynamicMap)
              else type(hvobj)
          )
          if getattr(
              eltype, "_selection_dims", None
          ) == 1 or issubclass(eltype, Histogram):
              layers.insert(1, region)
          else:
              layers.append(region)
      return Overlay(layers).collate()
  
imports: from collections import namedtuple
  import numpy
  import param
  from param.parameterized import bothmethod
  from .core.data import Dataset
  from .core.element import Element, Layout
  from .core.layout import AdjointLayout
  from .core.options import CallbackError, Store
  from .core.overlay import NdOverlay, Overlay
  from .core.spaces import GridSpace
  from .streams import CrossFilterSet, Derived, Pipe, PlotReset, SelectionExprSequence, SelectMode, Stream
  from .util import DynamicMap
label_desc: Use image node_id 3 for calling the OverlaySelectionDisplay obj's underlying member method code with example usage: obj.build_selection(selection_streams, hvobj, operations, region_stream, cache) and returns: Overlay, Overlay, self