code: def random_transformer_dataset(
      num_samples,
      max_length=60,
      num_classes=2,
      multi_label=False,
      num_tokens=1000,
      target_labels="inferred",
      dtype=torch.long,
  ):
      if target_labels not in ["explicit", "inferred"]:
          raise ValueError(
              f"Invalid test parameter value for target_labels: {str(target_labels)}"
          )
  
      data = []
      for i in range(num_samples):
          sample_length = np.random.randint(1, max_length)
          text = torch.cat(
              [
                  torch.randint(
                      num_tokens, (sample_length,), dtype=dtype
                  )
                  + 1,
                  torch.tensor(
                      [0] * (max_length - sample_length), dtype=dtype
                  ),
              ]
          ).unsqueeze(0)
          mask = torch.cat(
              [
                  torch.tensor([1] * sample_length, dtype=dtype),
                  torch.tensor(
                      [0] * (max_length - sample_length), dtype=dtype
                  ),
              ]
          ).unsqueeze(0)
          if multi_label:
              labels = np.sort(
                  random_labeling(num_classes, multi_label)
              )
          else:
              labels = random_labeling(num_classes, multi_label)
  
          data.append((text, mask, labels))
  
      data = assure_all_labels_occur(
          data, num_classes, multi_label=multi_label
      )
  
      target_labels = (
          None
          if target_labels == "inferred"
          else np.arange(num_classes)
      )
      return TransformersDataset(
          data, multi_label=multi_label, target_labels=target_labels
      )
  
imports: import string
  import numpy
  from collections import Counter
  from scipy import sparse
  from sklearn.datasets import fetch_20newsgroups
  from small_text.data.datasets import SklearnDataset, TextDataset
  from small_text.data.sampling import _get_class_histogram
  from small_text.utils.labels import csr_to_list, list_to_csr
label_desc: Use image node_id 11 for calling a global function with example usage: random_transformer_dataset(num_samples, max_length, num_classes, multi_label, num_tokens, target_labels, dtype) and returns: TransformersDataset