code: def validate_fontweight(s):
      weights = [
          "ultralight",
          "light",
          "normal",
          "regular",
          "book",
          "medium",
          "roman",
          "semibold",
          "demibold",
          "demi",
          "bold",
          "heavy",
          "extra bold",
          "black",
      ]
      # Note: Historically, weights have been case-sensitive in Matplotlib
      if s in weights:
          return s
      try:
          return int(s)
      except (ValueError, TypeError) as e:
          raise ValueError(f"{s} is not a valid font weight.") from e
  
imports: import ast
  from functools import lru_cache, reduce
  from numbers import Real
  import operator
  import os
  import re
  import numpy
  from matplotlib import _api, cbook
  from matplotlib.cbook import ls_mapper
  from matplotlib.colors import Colormap, is_color_like
  from matplotlib._fontconfig_pattern import parse_fontconfig_pattern
  from matplotlib._enums import JoinStyle, CapStyle
  from cycler import Cycler, cycler
label_desc: Use image node_id 21 for calling a global function with example usage: validate_fontweight(s) and returns: s, int