code: def down(db, dataset_name):
      match_d = {"name": dataset_name}
      dataset_dict = db.datasets.find_one(match_d)
      sample_coll = dataset_dict["sample_collection_name"]
      frame_coll = "frames.%s" % sample_coll
  
      for field in (
          dataset_dict["sample_fields"] + dataset_dict["frame_fields"]
      ):
          field["media_type"] = None
          if (
              field["name"] == "frames"
              and dataset_dict["media_type"] == "video"
          ):
              field["ftype"] = "fiftyone.core.fields.FramesField"
              field["subfield"] = "fiftyone.core.fields.ReferenceField"
              field["embedded_doc_type"] = None
  
      if "version" in dataset_dict:
          del dataset_dict["version"]
  
      db.datasets.replace_one(match_d, dataset_dict)
  
      for s in db[sample_coll].find():
          frames = {}
          frame_writes = []
          _down_convert_polyline_points(s)
          for f in db[frame_coll].find({"_sample_id": s["_id"]}):
              frames[str(f["frame_number"])] = f["_id"]
              converted = False
              for d in f.values():
                  converted |= _down_convert_polyline_points(d)
  
              if converted:
                  frame_writes.append(
                      pm.ReplaceOne({"_id": f["_id"]}, f)
                  )
  
          if len(frame_writes):
              db[frame_coll].bulk_write(frame_writes, ordered=False)
  
          db[sample_coll].replace_one({"_id": s["_id"]}, s)
  
      db[frame_coll].update(
          {}, {"$unset": {"_sample_id": ""}}, multi=True, upsert=True
      )
  
imports: import pymongo
label_desc: Use image node_id 4 for calling a global function with example usage: down(db, dataset_name) without return types