docstr: Return key in given units
docstr_tok: ["Return","key","in","given","units"]
code: def get_as(
      self,
      loc: Literal["t", "b", "l", "r"],
      units: Literal["pt", "in", "lines", "fig"] = "pt",
  ) -> float:
      """
      Return key in given units
      """
      assert self.theme is not None
      dpi = 72
      # TODO: Get the inherited size. We need to consider the
      # themeables mro
      size: float = self.element.properties.get("size", 11)
      from_units = self.units
      to_units = units
      W: float
      H: float
      W, H = self.theme.themeables.property("figure_size")  # inches
      L = (W * dpi) if loc in "tb" else (H * dpi)  # pts
  
      functions: dict[str, Callable[[float], float]] = {
          "fig-in": lambda x: x * L / dpi,
          "fig-lines": lambda x: x * L / size,
          "fig-pt": lambda x: x * L,
          "in-fig": lambda x: x * dpi / L,
          "in-lines": lambda x: x * dpi / size,
          "in-pt": lambda x: x * dpi,
          "lines-fig": lambda x: x * size / L,
          "lines-in": lambda x: x * size / dpi,
          "lines-pt": lambda x: x * size,
          "pt-fig": lambda x: x / L,
          "pt-in": lambda x: x / dpi,
          "pt-lines": lambda x: x / size,
      }
  
      value: float = getattr(self, loc)
      if from_units != to_units:
          conversion = f"{self.units}-{units}"
          try:
              value = functions[conversion](value)
          except ZeroDivisionError:
              value = 0
      return value
  
imports: from __future__ import annotations
  from dataclasses import dataclass
  from typing import TYPE_CHECKING
label_desc: Use image node_id 3 for calling the Margin obj's underlying member method code with example usage: obj.get_as(loc, units) and returns: value