code: def _avoid_duplicate_arrays(types):
      
      arrays = [t for t in types if isinstance(t, dict) and t["type"] == "array"]
      others = [t for t in types if not (isinstance(t, dict) and t["type"] == "array")]
      if arrays:
          items = set([])
          for t in arrays:
              if isinstance(t["items"], (list, tuple)):
                  items |= set(t["items"])
              else:
                  items.add(t["items"])
          if len(items) == 1:
              items = items.pop()
          else:
              items = sorted(list(items))
          arrays = [{"type": "array", "items": items}]
      return others + arrays
docs: Collapse arrays when we have multiple types.