code: def test_guess_sorting_key_picks_the_longest_key(self):
      sampler = MaxTokensBatchSampler(max_tokens=8, padding_noise=0)
      instances = []
      short_tokens = [Token(t) for t in ["what", "is", "this", "?"]]
      long_tokens = [
          Token(t)
          for t in ["this", "is", "a", "not", "very", "long", "passage"]
      ]
      instances.append(
          Instance(
              {
                  "question": TextField(
                      short_tokens, self.token_indexers
                  ),
                  "passage": TextField(
                      long_tokens, self.token_indexers
                  ),
              }
          )
      )
      instances.append(
          Instance(
              {
                  "question": TextField(
                      short_tokens, self.token_indexers
                  ),
                  "passage": TextField(
                      long_tokens, self.token_indexers
                  ),
              }
          )
      )
      instances.append(
          Instance(
              {
                  "question": TextField(
                      short_tokens, self.token_indexers
                  ),
                  "passage": TextField(
                      long_tokens, self.token_indexers
                  ),
              }
          )
      )
      assert sampler.sorting_keys is None
      sampler._guess_sorting_keys(instances)
      assert sampler.sorting_keys == ["passage"]
  
file_path: allennlp/tests/data/samplers/max_tokens_batch_sampler_test.py
imports: from allennlp.data import Instance, Token
  from allennlp.data.fields import TextField
  from allennlp.data.samplers import MaxTokensBatchSampler
  from allennlp.data.data_loaders import MultiProcessDataLoader
  from .sampler_test import SamplerTest
label_desc: Use image node_id 2 for calling the TestMaxTokensSampler obj's underlying member method code with example usage: obj.test_guess_sorting_key_picks_the_longest_key() without return types