code: def enum(*values, **kwargs):
      """Generates an enum function that only accepts particular values. Other
      values will raise a ValueError.
  
      Parameters
      ----------
  
      values : list
          These are the acceptable values.
  
      type : type
          The acceptable types of values. Values will be converted before being
          checked against the allowed values. If not specified, no conversion
          will be performed.
  
      Example
      -------
  
      >>> my_enum = enum(1, 2, 3, 4, 5, type=int)
      >>> a = my_enum(1)
      >>> b = my_enum(2)
      >>> c = mu_enum(6) # Raises ValueError
  
      """
      if len(values) < 1:
          raise ValueError("At least one value is required.")
      enum_type = kwargs.pop("type", str)
      if kwargs:
          raise TypeError(
              f'Unexpected parameters: {", ".join(kwargs.keys())}'
          )
  
      def __new__(cls, value):
          if value not in cls.values:
              raise ValueError(
                  f"{value} is an unexpected value. "
                  f"Expected one of {cls.values}"
              )
  
          return super(enum, cls).__new__(cls, value)
  
      enum = type(
          "Enum", (enum_type,), {"values": values, "__new__": __new__}
      )
  
      return enum
  
imports: import abc
  from collections.abc import MutableMapping
  import logging
  import requests
  from requests.auth import HTTPBasicAuth
  from re import compile
  import json
label_desc: Use image node_id 1 for calling a global function with example usage: enum() and returns: enum, super