code: def _first(
      path: str,
      dataset: fo.Dataset,
      sort: t.Union[t.Literal[-1], t.Literal[1]],
      is_frame_field: bool,
  ):
      pipeline = [{"$sort": {path: sort}}]
  
      if sort:
          pipeline.append({"$match": {path: {"$ne": None}}})
  
      pipeline.append({"$limit": 1})
  
      unwound = _unwind(dataset, path, is_frame_field)
  
      if unwound:
          pipeline += unwound
          if sort:
              pipeline.append({"$match": {path: {"$ne": None}}})
  
      return pipeline + [
          {
              "$group": {
                  "_id": {"$min" if sort == 1 else "$max": f"${path}"}
              }
          }
      ]
  
imports: from dataclasses import asdict, dataclass
  from datetime import date, datetime
  import math
  import typing
  import asyncio
  from bson.regex import Regex
  from motor.motor_asyncio import AsyncIOMotorCollection
  import strawberry
  import fiftyone
  import fiftyone.core.fields
  import fiftyone.server.constants
  from fiftyone.server.data import Info
  from fiftyone.server.utils import meets_type
label_desc: Use image node_id 2 for calling a global function with example usage: _first(path, dataset, sort, is_frame_field) and returns: unknown