code: def requirements_to_query_filter(
      req: Optional[Requirements],
  ) -> gpuhunt.QueryFilter:
      q = gpuhunt.QueryFilter()
      if req is None:
          return q
      q.min_cpu = req.cpus
      q.max_price = req.max_price
      q.min_disk_size = (
          req.disk.size_mib / 1024
          if req.disk and req.disk.size_mib
          else None
      )
      q.spot = req.spot
      if req.memory_mib is not None:
          q.min_memory = req.memory_mib / 1024
      if req.gpus is not None:
          if req.gpus.name is not None:
              q.gpu_name = [req.gpus.name]
          if req.gpus.memory_mib is not None:
              q.min_gpu_memory = req.gpus.memory_mib / 1024
          if req.gpus.count is not None:
              q.min_gpu_count = req.gpus.count
          if req.gpus.total_memory_mib is not None:
              q.min_total_gpu_memory = req.gpus.total_memory_mib / 1024
          if req.gpus.compute_capability is not None:
              q.min_compute_capability = req.gpus.compute_capability
      return q
  
file_path: dstack/src/dstack/_internal/core/backends/base/offers.py
imports: from dataclasses import asdict
  from typing import Callable, List, Optional
  import gpuhunt
  from dstack._internal.core.models.backends.base import BackendType
  from dstack._internal.core.models.instances import Disk, Gpu, InstanceOffer, InstanceType, Resources
  from dstack._internal.core.models.runs import Requirements
label_desc: Use image node_id 3 for calling a global function with example usage: requirements_to_query_filter(req) and returns: q, q