code: def test_annotations(self):
      ds_spec = {
          "text": types.TextSegment(),
      }
      out_spec = {
          "tokens": types.Tokens(),
          "spans": types.SpanLabels(align="tokens"),
          "edges": types.EdgeLabels(align="tokens"),
          "annot": types.MultiSegmentAnnotations(),
      }
      example = {"text": "hi"}
      output = {
          "tokens": ["hi"],
          "preds": [dtypes.SpanLabel(start=0, end=1)],
          "edges": [
              dtypes.EdgeLabel(span1=(0, 0), span2=(1, 1), label=0)
          ],
          "annot": [dtypes.AnnotationCluster(label="hi", spans=[])],
      }
  
      spans = types.SpanLabels(align="tokens")
      edges = types.EdgeLabels(align="tokens")
      annot = types.MultiSegmentAnnotations()
      try:
          spans.validate_output(
              [dtypes.SpanLabel(start=0, end=1)],
              out_spec,
              output,
              ds_spec,
              ds_spec,
              example,
          )
          edges.validate_output(
              [dtypes.EdgeLabel(span1=(0, 0), span2=(1, 1), label=0)],
              out_spec,
              output,
              ds_spec,
              ds_spec,
              example,
          )
          annot.validate_output(
              [dtypes.AnnotationCluster(label="hi", spans=[])],
              out_spec,
              output,
              ds_spec,
              ds_spec,
              example,
          )
      except ValueError:
          self.fail("Raised unexpected error.")
  
      self.assertRaises(
          ValueError,
          spans.validate_output,
          [1],
          out_spec,
          output,
          ds_spec,
          ds_spec,
          example,
      )
      self.assertRaises(
          ValueError,
          edges.validate_output,
          [1],
          out_spec,
          output,
          ds_spec,
          ds_spec,
          example,
      )
      self.assertRaises(
          ValueError,
          annot.validate_output,
          [1],
          out_spec,
          output,
          ds_spec,
          ds_spec,
          example,
      )
  
      bad_spans = types.SpanLabels(align="edges")
      bad_edges = types.EdgeLabels(align="spans")
      self.assertRaises(
          ValueError,
          bad_spans.validate_output,
          [dtypes.SpanLabel(start=0, end=1)],
          out_spec,
          output,
          ds_spec,
          ds_spec,
          example,
      )
      self.assertRaises(
          ValueError,
          bad_edges.validate_output,
          [dtypes.EdgeLabel(span1=(0, 0), span2=(1, 1), label=0)],
          out_spec,
          output,
          ds_spec,
          ds_spec,
          example,
      )
  
imports: from collections.abc import Callable
  import os
  from typing import Any, Optional, Union
  from absl.testing import absltest
  from absl.testing import parameterized
  from etils import epath
  from lit_nlp.api import dtypes
  from lit_nlp.api import types
  import numpy
label_desc: Use image node_id 17 for calling the TypesTest obj's underlying member method code with example usage: obj.test_annotations() without return types