<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _stripe_object_to_invoice_items(cls, target_cls, data, invoice):
 		""" 		Retrieves InvoiceItems for an invoice. 		If the invoice item doesn't exist already then it is created. 		If the invoice is an upcoming invoice that doesn't persist to the 		database (i.e. ephemeral) then the invoice items are also not saved. 		:param target_cls: The target class to instantiate per invoice item. 		:type target_cls: ``InvoiceItem`` 		:param data: The data dictionary received from the Stripe API. 		:type data: dict 		:param invoice: The invoice object that should hold the invoice items. 		:type invoice: ``djstripe.models.Invoice`` 		"""


		lines = data.get("lines")
		if not lines:
			return []

		invoiceitems = []
		for line in lines.get("data", []):
			if invoice.id:
				save = True
				line.setdefault("invoice", invoice.id)

				if line.get("type") == "subscription":
					# Lines for subscriptions need to be keyed based on invoice and
					# subscription, because their id is *just* the subscription
					# when received from Stripe. This means that future updates to
					# a subscription will change previously saved invoices - Doing
					# the composite key avoids this.
					if not line["id"].startswith(invoice.id):
						line["id"] = "{invoice_id}-{subscription_id}".format(
							invoice_id=invoice.id, subscription_id=line["id"]
						)
			else:
				# Don't save invoice items for ephemeral invoices
				save = False

			line.setdefault("customer", invoice.customer.id)
			line.setdefault("date", int(dateformat.format(invoice.date, "U")))

			item, _ = target_cls._get_or_create_from_stripe_object(
				line, refetch=False, save=save
			)
			invoiceitems.append(item)

		return invoiceitems