code: def _make_scalar_expression(
      f, args, field, list_field=False, is_label=False
  ):
      expr = None
      if _is_support(field):
          mn, mx = args["range"]
          expr = (f[0] >= mn) & (f[1] <= mx)
      elif isinstance(field, fof.ListField):
          expr = f.filter(
              _make_scalar_expression(
                  F(), args, field.field, list_field=True
              )
          ).length()
          return expr == 0 if args["exclude"] else expr > 0
      elif isinstance(field, fof.BooleanField):
          true, false = args["true"], args["false"]
          if true and false:
              expr = f.is_in([True, False])
  
          if not true and false:
              expr = f == False
  
          if true and not false:
              expr = f == True
  
          if not true and not false:
              expr = (f != True) & (f != False)
      elif _is_datetime(field):
          mn, mx = args["range"]
          p = fou.timestamp_to_datetime
          expr = (f >= p(mn)) & (f <= p(mx))
      elif isinstance(field, (fof.FloatField, fof.IntField)):
          mn, mx = args["range"]
          expr = (f >= mn) & (f <= mx)
      else:
          values = args["values"]
          if not values:
              return None
  
          if isinstance(field, fof.ObjectIdField):
              f = f.to_string()
  
          none = any(map(lambda v: v is None, values))
          values = filter(lambda v: v is not None, values)
          expr = f.is_in(values)
          exclude = args["exclude"]
  
          if exclude:
              # pylint: disable=invalid-unary-operand-type
              expr = ~expr
  
          if none and not is_label and not list_field:
              if exclude:
                  expr &= f.exists()
              else:
                  expr |= ~(f.exists())
  
          return expr
  
      return _apply_others(expr, f, args, is_label)
  
imports: from typing import List, Optional
  from bson import ObjectId
  import strawberry
  import fiftyone.core.collections
  import fiftyone.core.dataset
  from fiftyone.core.expressions import ViewField, VALUE
  import fiftyone.core.fields
  import fiftyone.core.labels
  import fiftyone.core.media
  import fiftyone.core.stages
  import fiftyone.core.utils
  import fiftyone.core.view
  from fiftyone.server.aggregations import GroupElementFilter, SampleFilter
  from fiftyone.server.scalars import BSONArray, JSON
label_desc: Use image node_id 13 for calling a global function with example usage: _make_scalar_expression(f, args, field, list_field, is_label) and returns: _apply_others, unknown, expr, None