  
      def _get_span_slices(self, entities: List[Dict]) -> str:
          """Get the rendered markup of all Span slices"""
          span_slices = []
          for entity, step in zip(entities, itertools.count(step=self.offset_step)):
              color = self.colors.get(entity["label"].upper(), self.default_color)
              span_slice = self.span_slice_template.format(
                  bg=color, top_offset=self.top_offset + step
              )
              span_slices.append(span_slice)
 
</s> remove         for entity, step in zip(entities, itertools.count(step=self.offset_step)):
 </s> add         for entity in entities: </s> remove                 bg=color, top_offset=self.top_offset + step
 </s> add                 bg=color,
                top_offset=top_offset, </s> remove             entities = sorted(token["entities"], key=lambda d: d["label"])
            if entities:
 </s> add             entities = sorted(token["entities"], key=lambda d: d["render_slot"])
            # Whitespace tokens disrupt the vertical space (no line height) so that the
            # span indicators get misaligned. We don't render them as individual
            # tokens anyway, so we'll just not display a span indicator either.
            is_whitespace = token["text"].strip() == ""
            if entities and not is_whitespace:
        for entity in entities:
            # rather than iterate over multiples of offset_step, we use entity['render_slot']
            # to determine the vertical position, since that tells where
            # the span starts vertically so we can extend it horizontally,
            # past other spans that might have already ended
  
      def _get_span_slices(self, entities: List[Dict]) -> str:
          """Get the rendered markup of all Span slices"""
          span_slices = []
        for entity in entities:
            # rather than iterate over multiples of offset_step, we use entity['render_slot']
            # to determine the vertical position, since that tells where
            # the span starts vertically so we can extend it horizontally,
            # past other spans that might have already ended
              color = self.colors.get(entity["label"].upper(), self.default_color)
              span_slice = self.span_slice_template.format(
                  bg=color, top_offset=self.top_offset + step
              )
              span_slices.append(span_slice)
keep keep keep keep replace keep keep keep keep keep
 displaCy Spans Vertical Alignment Fix 2 (#11092)

* add in span render slot fix

* fix spacing off by one

* rm demo

* adjust comments

* fix whitespace and overlap issue 
spacy/displacy/render.py