code: def _ensure_filesystem(fs):
      fs_type = type(fs)
  
      # If the arrow filesystem was subclassed, assume it supports the full
      # interface and return it
      if not issubclass(fs_type, FileSystem):
          if "fsspec" in sys.modules:
              fsspec = sys.modules["fsspec"]
              if isinstance(fs, fsspec.AbstractFileSystem):
                  # for recent fsspec versions that stop inheriting from
                  # pyarrow.filesystem.FileSystem, still allow fsspec
                  # filesystems (which should be compatible with our legacy fs)
                  return fs
  
          raise OSError("Unrecognized filesystem: {}".format(fs_type))
      else:
          return fs
  
imports: import os
  import posixpath
  import sys
  import urllib.parse
  import warnings
  from os.path import join
  import pyarrow
  from pyarrow.util import doc, _stringify_path, _is_path_like, _DEPR_MSG
label_desc: Use image node_id 2 for calling a global function with example usage: _ensure_filesystem(fs) and returns: fs, fs