class_docstr: Traitlet class storing a JupyterChart's selections
code: def __init__(self, trait_values):
      super().__init__()
  
      for key, value in trait_values.items():
          if isinstance(value, IndexSelection):
              traitlet_type = traitlets.Instance(IndexSelection)
          elif isinstance(value, PointSelection):
              traitlet_type = traitlets.Instance(PointSelection)
          elif isinstance(value, IntervalSelection):
              traitlet_type = traitlets.Instance(IntervalSelection)
          else:
              raise ValueError(
                  f"Unexpected selection type: {type(value)}"
              )
  
          # Add the new trait.
          self.add_traits(**{key: traitlet_type})
  
          # Set the trait's value.
          setattr(self, key, value)
  
          # Make read-only
          self.observe(self._make_read_only, names=key)
  
imports: import json
  import anywidget
  import traitlets
  import pathlib
  from typing import Any, Set, Optional
  import altair
  from altair.utils._vegafusion_data import using_vegafusion, compile_to_vegafusion_chart_state
  from altair import TopLevelSpec
  from altair.utils.selection import IndexSelection, PointSelection, IntervalSelection
label_desc: Use image node_id 1 to create a new Selections object from inherited base classes: traitlets with example: obj = Selections(trait_values)