code: def test_bmes_tags_to_spans_extracts_correct_spans(self):
      tag_sequence = [
          "B-ARG1",
          "M-ARG1",
          "E-ARG1",
          "B-ARG2",
          "E-ARG2",
          "S-ARG3",
      ]
      spans = span_utils.bmes_tags_to_spans(tag_sequence)
      assert set(spans) == {
          ("ARG1", (0, 2)),
          ("ARG2", (3, 4)),
          ("ARG3", (5, 5)),
      }
  
      tag_sequence = ["S-ARG1", "B-ARG2", "E-ARG2", "S-ARG3"]
      spans = span_utils.bmes_tags_to_spans(tag_sequence)
      assert set(spans) == {
          ("ARG1", (0, 0)),
          ("ARG2", (1, 2)),
          ("ARG3", (3, 3)),
      }
  
      # Invalid labels.
      tag_sequence = ["B-ARG1", "M-ARG2"]
      spans = span_utils.bmes_tags_to_spans(tag_sequence)
      assert set(spans) == {("ARG1", (0, 0)), ("ARG2", (1, 1))}
  
      tag_sequence = ["B-ARG1", "E-ARG2"]
      spans = span_utils.bmes_tags_to_spans(tag_sequence)
      assert set(spans) == {("ARG1", (0, 0)), ("ARG2", (1, 1))}
  
      tag_sequence = ["B-ARG1", "M-ARG1", "M-ARG2"]
      spans = span_utils.bmes_tags_to_spans(tag_sequence)
      assert set(spans) == {("ARG1", (0, 1)), ("ARG2", (2, 2))}
  
      tag_sequence = ["B-ARG1", "M-ARG1", "E-ARG2"]
      spans = span_utils.bmes_tags_to_spans(tag_sequence)
      assert set(spans) == {("ARG1", (0, 1)), ("ARG2", (2, 2))}
  
      # Invalid transitions.
      tag_sequence = ["B-ARG1", "B-ARG1"]
      spans = span_utils.bmes_tags_to_spans(tag_sequence)
      assert set(spans) == {("ARG1", (0, 0)), ("ARG1", (1, 1))}
  
      tag_sequence = ["B-ARG1", "S-ARG1"]
      spans = span_utils.bmes_tags_to_spans(tag_sequence)
      assert set(spans) == {("ARG1", (0, 0)), ("ARG1", (1, 1))}
  
file_path: allennlp/tests/data/dataset_readers/dataset_utils/span_utils_test.py
imports: from typing import List
  import pytest
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.data.dataset_readers.dataset_utils import span_utils
  from allennlp.data.tokenizers import Token, SpacyTokenizer
label_desc: Use image node_id 11 for calling the SpanUtilsTest obj's underlying member method code with example usage: obj.test_bmes_tags_to_spans_extracts_correct_spans() without return types