code: def test_sortish_sampler_reduces_padding(self):
      ds, _, tokenizer = self._get_dataset(max_len=512)
      bs = 2
      sortish_sampler = ds.make_sortish_sampler(bs, shuffle=False)
  
      naive_dl = DataLoader(
          ds, batch_size=bs, collate_fn=ds.collate_fn, num_workers=2
      )
      sortish_dl = DataLoader(
          ds,
          batch_size=bs,
          collate_fn=ds.collate_fn,
          num_workers=2,
          sampler=sortish_sampler,
      )
  
      pad = tokenizer.pad_token_id
  
      def count_pad_tokens(data_loader, k="input_ids"):
          return [
              batch[k].eq(pad).sum().item() for batch in data_loader
          ]
  
      assert sum(count_pad_tokens(sortish_dl, k="labels")) < sum(
          count_pad_tokens(naive_dl, k="labels")
      )
      assert sum(count_pad_tokens(sortish_dl)) < sum(
          count_pad_tokens(naive_dl)
      )
      assert len(sortish_dl) == len(naive_dl)
  
imports: import os
  from pathlib import Path
  import numpy
  import pytest
  from torch.utils.data import DataLoader
  from pack_dataset import pack_data_dir
  from parameterized import parameterized
  from save_len_file import save_len_file
  from transformers import AutoTokenizer
  from transformers.models.mbart.modeling_mbart import shift_tokens_right
  from transformers.testing_utils import TestCasePlus, slow
  from utils import FAIRSEQ_AVAILABLE, DistributedSortishSampler, LegacySeq2SeqDataset, Seq2SeqDataset
label_desc: Use image node_id 5 for calling the TestAll obj's underlying member method code with example usage: obj.test_sortish_sampler_reduces_padding() and returns: unknown