code: def get_batch(
      batch_size,
      avg_seqlen,
      max_sequence_length,
      seqlen_stdev,
      vocab_size=30522,
      pad_idx=0,
  ):
      r"""
      Utility function to generate a batch of random sequences, together with their
      attention mask and lengths.
      Copied from: https://github.com/HamidShojanazeri/transformers/blob/ddf0299a13e7c4f54459a0731abd80204a1078f5/examples/pytorch/benchmarking/benchmark_bettertransformer.py#L149
      """
      mean_tensor = torch.Tensor([avg_seqlen]).expand(batch_size)
      stdev_tensor = torch.Tensor([seqlen_stdev]).expand(batch_size)
      lengths = torch.normal(mean_tensor, stdev_tensor).to(torch.int)
      lengths = torch.clamp(lengths, min=0, max=max_sequence_length)
  
      tokens = torch.full(
          (batch_size, max_sequence_length),
          pad_idx,
      )
      # lengths[0:2] = max_sequence_length-1
      for i in range(batch_size):
          tokens[i, : lengths[i]] = torch.randint(
              pad_idx + 1,
              vocab_size - 1,
              size=(lengths[i],),
          )
      mask = torch.full(
          (batch_size, max_sequence_length),
          0,
      )
      for i in range(batch_size):
          mask[i, : lengths[i]] = 1
      return tokens, lengths, mask
  
file_path: optimum/tests/benchmark/benchmark_bettertransformer.py
imports: import argparse
  import numpy
  import pandas
  import torch
  from tqdm import tqdm
  from transformers import AutoModel, AutoModelForCausalLM, AutoModelForSeq2SeqLM, AutoTokenizer, GenerationConfig
  from optimum.bettertransformer import BetterTransformer
  from optimum.exporters import TasksManager
label_desc: Use image node_id 2 for calling a global function with example usage: get_batch(batch_size, avg_seqlen, max_sequence_length, seqlen_stdev, vocab_size, pad_idx) and returns: tokens,  lengths,  mask