code: def userRegionToDesignRegion(
      doc: DesignSpaceDocument, userRegion: Region
  ) -> Region:
      designRegion = {}
      for name, value in userRegion.items():
          axis = doc.getAxis(name)
          if axis is None:
              raise DesignSpaceDocumentError(
                  f"Cannot find axis named '{name}' for region."
              )
          if isinstance(value, (float, int)):
              designRegion[name] = axis.map_forward(value)
          else:
              designRegion[name] = Range(
                  axis.map_forward(value.minimum),
                  axis.map_forward(value.maximum),
                  axis.map_forward(value.default),
              )
      return designRegion
  
file_path: catboost/contrib/python/fonttools/fontTools/designspaceLib/types.py
imports: from __future__ import annotations
  from dataclasses import dataclass
  from typing import Dict, List, Optional, Union, cast
  from fontTools.designspaceLib import AxisDescriptor, DesignSpaceDocument, DesignSpaceDocumentError, RangeAxisSubsetDescriptor, SimpleLocationDict, ValueAxisSubsetDescriptor, VariableFontDescriptor
label_desc: Use image node_id 4 for calling a global function with example usage: userRegionToDesignRegion(doc, userRegion) and returns: designRegion