code: def test_sort(self):
      data = Data(
          self.data_source,
          self.tensorizers,
          Batcher(train_batch_size=5),
          sort_key="tokens",
      )
  
      def assert_sorted(batch):
          _, seq_lens, _ = batch["tokens"]
          seq_lens = seq_lens.tolist()
          for i in range(len(seq_lens) - 1):
              self.assertTrue(seq_lens[i] >= seq_lens[i + 1])
  
      batches = iter(list(data.batches(Stage.TRAIN)))
      first_raw_batch, first_batch = next(batches)
      assert_sorted(first_batch)
      # make sure labels are also in the same order of sorted tokens
      self.assertEqual(
          self.tensorizers["labels"].vocab[first_batch["labels"][1]],
          "alarm/set_alarm",
      )
      self.assertEqual(
          first_raw_batch[1][RawExampleFieldName.ROW_INDEX], 1
      )
      second_raw_batch, second_batch = next(batches)
      assert_sorted(second_batch)
      self.assertEqual(
          self.tensorizers["labels"].vocab[second_batch["labels"][1]],
          "alarm/time_left_on_alarm",
      )
      self.assertEqual(
          second_raw_batch[0][RawExampleFieldName.ROW_INDEX], 6
      )
      self.assertEqual(
          second_raw_batch[1][RawExampleFieldName.ROW_INDEX], 5
      )
  
imports: import unittest
  from pytext.common.constants import RawExampleFieldName, Stage
  from pytext.data import Batcher, Data, PoolingBatcher
  from pytext.data.data import RowData
  from pytext.data.sources import RawExample
  from pytext.data.sources.data_source import SafeFileWrapper
  from pytext.data.sources.tsv import TSVDataSource
  from pytext.data.tensorizers import LabelTensorizer, TokenTensorizer
  from pytext.data.utils import pad
  from pytext.utils import precision
  from pytext.utils.test import import_tests_module
label_desc: Use image node_id 7 for calling the DataTest obj's underlying member method code with example usage: obj.test_sort() without return types