code: def gen_paginated(defs: swagger_parser.TypeDefs) -> typing.List[str]:
      paginated = []
      for k, defn in defs.items():
          defn = defs[k]
          if defn is None or not isinstance(defn, swagger_parser.Class):
              continue
          # Note that our goal is to mimic duck typing, so we only care if the "pagination" attribute
          # exists with a v1Pagination type.
          if any(
              n == "pagination" and p.type.name == "v1Pagination"
              for n, p in defn.params.items()
          ):
              paginated.append(defn.name)
  
      if not paginated:
          return []
  
      out = []
      out += [
          "# Paginated is a union type of objects whose .pagination"
      ]
      out += ["# attribute is a v1Pagination-type object."]
      out += ["Paginated = typing.Union["]
      out += [f"    {name}," for name in sorted(paginated)]
      out += ["]"]
      return out
  
imports: import os
  import typing
  import swagger_parser
  from typing_extensions import assert_never
label_desc: Use image node_id 16 for calling a global function with example usage: gen_paginated(defs) and returns: out, list