code: def apriori(transactions, **kwargs):
      
      # Parse the arguments.
      min_support = kwargs.get('min_support', 0.1)
      min_confidence = kwargs.get('min_confidence', 0.0)
      min_lift = kwargs.get('min_lift', 0.0)
      max_length = kwargs.get('max_length', None)
  
      # Check arguments.
      if min_support <= 0:
          raise ValueError('minimum support must be > 0')
  
      # For testing.
      _gen_support_records = kwargs.get(
          '_gen_support_records', gen_support_records)
      _gen_ordered_statistics = kwargs.get(
          '_gen_ordered_statistics', gen_ordered_statistics)
      _filter_ordered_statistics = kwargs.get(
          '_filter_ordered_statistics', filter_ordered_statistics)
  
      # Calculate supports.
      transaction_manager = TransactionManager.create(transactions)
      support_records = _gen_support_records(
          transaction_manager, min_support, max_length=max_length)
  
      # Calculate ordered stats.
      for support_record in support_records:
          ordered_statistics = list(
              _filter_ordered_statistics(
                  _gen_ordered_statistics(transaction_manager, support_record),
                  min_confidence=min_confidence,
                  min_lift=min_lift,
              )
          )
          if not ordered_statistics:
              continue
          yield RelationRecord(
              support_record.items, support_record.support, ordered_statistics)
docs: Executes Apriori algorithm and returns a RelationRecord generator.
  
      Arguments:
          transactions -- A transaction iterable object
                          (eg. [['A', 'B'], ['B', 'C']]).
  
      Keyword arguments:
          min_support -- The minimum support of relations (float).
          min_confidence -- The minimum confidence of relations (float).
          min_lift -- The minimum lift of relations (float).
          max_length -- The maximum length of the relation (integer).