code: def open(
      fp,
      mode="r",
      driver=None,
      schema=None,
      crs=None,
      encoding=None,
      layer=None,
      vfs=None,
      enabled_drivers=None,
      crs_wkt=None,
      allow_unsupported_drivers=False,
      **kwargs,
  ):
      """Open a collection for read, append, or write
  
      In write mode, a driver name such as "ESRI Shapefile" or "GPX" (see
      OGR docs or ``ogr2ogr --help`` on the command line) and a schema
      mapping such as:
  
        {'geometry': 'Point',
         'properties': [('class', 'int'), ('label', 'str'),
                        ('value', 'float')]}
  
      must be provided. If a particular ordering of properties ("fields"
      in GIS parlance) in the written file is desired, a list of (key,
      value) pairs as above or an ordered dict is required. If no ordering
      is needed, a standard dict will suffice.
  
      A coordinate reference system for collections in write mode can be
      defined by the ``crs`` parameter. It takes Proj4 style mappings like
  
        {'proj': 'longlat', 'ellps': 'WGS84', 'datum': 'WGS84',
         'no_defs': True}
  
      short hand strings like
  
        EPSG:4326
  
      or WKT representations of coordinate reference systems.
  
      The drivers used by Fiona will try to detect the encoding of data
      files. If they fail, you may provide the proper ``encoding``, such
      as 'Windows-1252' for the original Natural Earth datasets.
  
      When the provided path is to a file containing multiple named layers
      of data, a layer can be singled out by ``layer``.
  
      The drivers enabled for opening datasets may be restricted to those
      listed in the ``enabled_drivers`` parameter. This and the ``driver``
      parameter afford much control over opening of files.
  
        # Trying only the GeoJSON driver when opening to read, the
        # following raises ``DataIOError``:
        fiona.open('example.shp', driver='GeoJSON')
  
        # Trying first the GeoJSON driver, then the Shapefile driver,
        # the following succeeds:
        fiona.open(
            'example.shp', enabled_drivers=['GeoJSON', 'ESRI Shapefile'])
  
      Parameters
      ----------
      fp : URI (str or pathlib.Path), or file-like object
          A dataset resource identifier or file object.
      mode : str
          One of 'r', to read (the default); 'a', to append; or 'w', to
          write.
      driver : str
          In 'w' mode a format driver name is required. In 'r' or 'a'
          mode this parameter has no effect.
      schema : dict
          Required in 'w' mode, has no effect in 'r' or 'a' mode.
      crs : str or dict
          Required in 'w' mode, has no effect in 'r' or 'a' mode.
      encoding : str
          Name of the encoding used to encode or decode the dataset.
      layer : int or str
          The integer index or name of a layer in a multi-layer dataset.
      vfs : str
          This is a deprecated parameter. A URI scheme such as "zip://"
          should be used instead.
      enabled_drivers : list
          An optional list of driver names to used when opening a
          collection.
      crs_wkt : str
          An optional WKT representation of a coordinate reference
          system.
      ignore_fields : list
          List of field names to ignore on load.
      ignore_geometry : bool
          Ignore the geometry on load.
      include_fields : list
          List of a subset of field names to include on load.
      wkt_version : fiona.enums.WktVersion or str, optional
          Version to use to for the CRS WKT.
          Defaults to GDAL's default (WKT1_GDAL for GDAL 3).
      allow_unsupported_drivers : bool
          If set to true do not limit GDAL drivers to set set of known working.
      kwargs : mapping
          Other driver-specific parameters that will be interpreted by
          the OGR library as layer creation or opening options.
  
      Returns
      -------
      Collection
  
      """
      if mode == "r" and hasattr(fp, "read"):
          memfile = MemoryFile(fp.read())
          colxn = memfile.open(
              driver=driver,
              crs=crs,
              schema=schema,
              layer=layer,
              encoding=encoding,
              enabled_drivers=enabled_drivers,
              allow_unsupported_drivers=allow_unsupported_drivers,
              **kwargs,
          )
          colxn._env.enter_context(memfile)
          return colxn
  
      elif mode == "w" and hasattr(fp, "write"):
          memfile = MemoryFile()
          colxn = memfile.open(
              driver=driver,
              crs=crs,
              schema=schema,
              layer=layer,
              encoding=encoding,
              enabled_drivers=enabled_drivers,
              allow_unsupported_drivers=allow_unsupported_drivers,
              crs_wkt=crs_wkt,
              **kwargs,
          )
          colxn._env.enter_context(memfile)
  
          # For the writing case we push an extra callback onto the
          # ExitStack. It ensures that the MemoryFile's contents are
          # copied to the open file object.
          def func(*args, **kwds):
              memfile.seek(0)
              fp.write(memfile.read())
  
          colxn._env.callback(func)
          return colxn
  
      elif mode == "a" and hasattr(fp, "write"):
          raise OSError(
              "Append mode is not supported for datasets in a Python file object."
          )
  
      # TODO: test for a shared base class or abstract type.
      elif isinstance(fp, MemoryFile):
          if mode.startswith("r"):
              colxn = fp.open(
                  driver=driver,
                  allow_unsupported_drivers=allow_unsupported_drivers,
                  **kwargs,
              )
  
          # Note: FilePath does not support writing and an exception will
          # result from this.
          elif mode.startswith("w"):
              colxn = fp.open(
                  driver=driver,
                  crs=crs,
                  schema=schema,
                  layer=layer,
                  encoding=encoding,
                  enabled_drivers=enabled_drivers,
                  allow_unsupported_drivers=allow_unsupported_drivers,
                  crs_wkt=crs_wkt,
                  **kwargs,
              )
          return colxn
  
      # At this point, the fp argument is a string or path-like object
      # which can be converted to a string.
      else:
          # If a pathlib.Path instance is given, convert it to a string path.
          if isinstance(fp, Path):
              fp = str(fp)
  
          if vfs:
              warnings.warn(
                  "The vfs keyword argument is deprecated and will be removed in version 2.0.0. Instead, pass a URL that uses a zip or tar (for example) scheme.",
                  FionaDeprecationWarning,
                  stacklevel=2,
              )
              path, scheme, archive = vfs_parse_paths(fp, vfs=vfs)
              path = ParsedPath(path, archive, scheme)
          else:
              path = parse_path(fp)
  
          if mode in ("a", "r"):
              colxn = Collection(
                  path,
                  mode,
                  driver=driver,
                  encoding=encoding,
                  layer=layer,
                  enabled_drivers=enabled_drivers,
                  allow_unsupported_drivers=allow_unsupported_drivers,
                  **kwargs,
              )
          elif mode == "w":
              colxn = Collection(
                  path,
                  mode,
                  crs=crs,
                  driver=driver,
                  schema=schema,
                  encoding=encoding,
                  layer=layer,
                  enabled_drivers=enabled_drivers,
                  crs_wkt=crs_wkt,
                  allow_unsupported_drivers=allow_unsupported_drivers,
                  **kwargs,
              )
          else:
              raise ValueError(
                  "mode string must be one of {'r', 'w', 'a'}"
              )
  
          return colxn
  
imports: import glob
  import logging
  import os
  from pathlib import Path
  import platform
  import warnings
  from fiona._env import calc_gdal_version_num, get_gdal_release_name, get_gdal_version_num, get_gdal_version_tuple
  from fiona._env import driver_count
  from fiona._show_versions import show_versions
  from fiona.collection import BytesCollection, Collection
  from fiona.drvsupport import supported_drivers
  from fiona.env import ensure_env_with_credentials, Env
  from fiona.errors import FionaDeprecationWarning
  from fiona.io import MemoryFile
  from fiona.model import Feature, Geometry, Properties
  from fiona.ogrext import FIELD_TYPES_MAP, _bounds, _listdir, _listlayers, _remove, _remove_layer
  from fiona.path import ParsedPath, parse_path, vsi_path
  from fiona.vfs import parse_paths
  from fiona import _geometry, _err, rfc3339
  import uuid
label_desc: Use image node_id 1 for calling a global function with example usage: open(fp, mode, driver, schema, crs, encoding, layer, vfs, enabled_drivers, crs_wkt, allow_unsupported_drivers) and returns: colxn, colxn, colxn, colxn