code: def replace_upside_down(
      texts: Union[str, List[str]],
      aug_p: float = 0.3,
      aug_min: int = 1,
      aug_max: int = 1000,
      granularity: str = "all",
      n: int = 1,
      metadata: Optional[List[Dict[str, Any]]] = None,
  ) -> Union[str, List[str]]:
      """
      Flips words in the text upside down depending on the granularity
  
      @param texts: a string or a list of text documents to be augmented
  
      @param aug_p: probability of words to be augmented
  
      @param aug_min: minimum # of words to be augmented
  
      @param aug_max: maximum # of words to be augmented
  
      @param granularity: the level at which the font is applied; this must be
          either word, char, or all
  
      @param n: number of augmentations to be performed for each text
  
      @param metadata: if set to be a list, metadata about the function execution
          including its name, the source & dest length, etc. will be appended to
          the inputted list. If set to None, no metadata will be appended or returned
  
      @returns: the list of augmented text documents
      """
      func_kwargs = txtutils.get_func_kwargs(metadata, locals())
  
      upside_down_aug = a.UpsideDownAugmenter(
          granularity, aug_min, aug_max, aug_p
      )
      aug_texts = upside_down_aug.augment(texts, n)
  
      txtutils.get_metadata(
          metadata=metadata,
          function_name="replace_upside_down",
          aug_texts=aug_texts,
          **func_kwargs,
      )
  
      return aug_texts
  
imports: from copy import deepcopy
  from typing import Any, Callable, Dict, List, Optional, Union
  from augly.text import augmenters, utils
  from augly.utils import CONTRACTIONS_MAPPING, FUN_FONTS_PATH, GENDERED_WORDS_MAPPING, MISSPELLING_DICTIONARY_PATH, UNICODE_MAPPING_PATH
label_desc: Use image node_id 15 for calling a global function with example usage: replace_upside_down(texts, aug_p, aug_min, aug_max, granularity, n, metadata) and returns: aug_texts