async def count_samples(db, label_id):
    return await db.samples.count_documents({"labels": {"$in": [label_id]}})

async def attach_sample_count(db, document, label_id):
    document.update({"count": await db.samples.count_documents({"labels": {"$in": [label_id]}})})

Rewrite function for sample count
Rewrite function for sample count

- async def count_samples(db, label_id):
+ async def attach_sample_count(db, document, label_id):
-     return await db.samples.count_documents({"labels": {"$in": [label_id]}})
+     document.update({"count": await db.samples.count_documents({"labels": {"$in": [label_id]}})})
  
Rewrite function for sample count
## Code Before:
async def count_samples(db, label_id):
    return await db.samples.count_documents({"labels": {"$in": [label_id]}})

## Instruction:
Rewrite function for sample count
## Code After:
async def attach_sample_count(db, document, label_id):
    document.update({"count": await db.samples.count_documents({"labels": {"$in": [label_id]}})})
