You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: labels_dependency.rb
    path of file: ./repos/bluedoc/app/models/issue
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

class Issue
  # has_and_belongs_to_many :assignees, join_table: :users, class_name: "User", foreign_key: :assigne
    
    def preload_labels
      label_ids = all.collect(&:label_ids).flatten.compact
      labels = Label.where(id: label_ids)
      records = all
      records.each do |item|
        item.labels = labels.select { |u| item.label_ids.include?(u.id) }
      end
      records
    end