code: def open(
          bucket_id,
          key_id,
          mode,
          buffer_size=DEFAULT_BUFFER_SIZE,
          min_part_size=DEFAULT_MIN_PART_SIZE,
          session=None,
          resource_kwargs=None,
          multipart_upload_kwargs=None,
          ):
      
      logger.debug('%r', locals())
      if mode not in MODES:
          raise NotImplementedError('bad mode: %r expected one of %r' % (mode, MODES))
  
      if resource_kwargs is None:
          resource_kwargs = {}
      if multipart_upload_kwargs is None:
          multipart_upload_kwargs = {}
  
      if mode == READ_BINARY:
          fileobj = SeekableBufferedInputBase(
              bucket_id,
              key_id,
              buffer_size=buffer_size,
              session=session,
              resource_kwargs=resource_kwargs,
          )
      elif mode == WRITE_BINARY:
          fileobj = BufferedOutputBase(
              bucket_id,
              key_id,
              min_part_size=min_part_size,
              session=session,
              multipart_upload_kwargs=multipart_upload_kwargs,
              resource_kwargs=resource_kwargs,
          )
      else:
          assert False, 'unexpected mode: %r' % mode
  
      return fileobj
docs: Open an S3 object for reading or writing.
  
      Parameters
      ----------
      bucket_id: str
          The name of the bucket this object resides in.
      key_id: str
          The name of the key within the bucket.
      mode: str
          The mode for opening the object.  Must be either "rb" or "wb".
      buffer_size: int, optional
          The buffer size to use when performing I/O.
      min_part_size: int, optional
          The minimum part size for multipart uploads.  For writing only.
      session: object, optional
          The S3 session to use when working with boto3.
      resource_kwargs: dict, optional
          Keyword arguments to use when accessing the S3 resource for reading or writing.
      multipart_upload_kwargs: dict, optional
          Additional parameters to pass to boto3's initiate_multipart_upload function.
          For writing only.