code: def generate_ngrams_range(tokens, ngram_range=(1, 3)):
      """Generates and returns a list of ngrams for all n present in ngram_range
  
      Args:
          tokens (List[str]): List of string tokens for which ngram are to be generated
          ngram_range (List[int], optional): List of 'n' for which ngrams are to be
              generated. For e.g. if ngram_range = (1, 4) then it will returns
              1grams, 2grams and 3grams. Defaults to (1, 3).
  
      Returns:
          List[str]: List of ngrams for each n in ngram_range
      """
      assert len(ngram_range) == 2, (
          "'ngram_range' should be a tuple"
          " of two elements which is range of numbers"
      )
      return chain(
          *(generate_ngrams(tokens, i) for i in range(*ngram_range))
      )
  
imports: import os
  import re
  from collections import Counter
  from itertools import chain
  import torch
  from mmf.common.registry import registry
  from mmf.utils.file_io import PathManager
  from mmf.utils.general import get_absolute_path
label_desc: Use image node_id 2 for calling a global function with example usage: generate_ngrams_range(tokens, ngram_range) and returns: chain