code: def get_domain(
      schema: schema_pb2.Schema,
      feature_path: Union[types.FeatureName, types.FeaturePath],
  ) -> Any:
      """Get the domain associated with the input feature from the schema.
  
      Args:
        schema: A Schema protocol buffer.
        feature_path: The path of the feature whose domain needs to be found. If a
          FeatureName is passed, a one-step FeaturePath will be constructed and
          used. For example, "my_feature" -> types.FeaturePath(["my_feature"])
  
      Returns:
        The domain protocol buffer associated with the input feature.
  
      Raises:
        TypeError: If the input schema is not of the expected type.
        ValueError: If the input feature is not found in the schema or there is
            no domain associated with the feature.
      """
      if not isinstance(schema, schema_pb2.Schema):
          raise TypeError(
              "schema is of type %s, should be a Schema proto."
              % type(schema).__name__
          )
  
      feature = get_feature(schema, feature_path)
      domain_info = feature.WhichOneof("domain_info")
  
      if domain_info is None:
          raise ValueError(
              "Feature %s has no domain associated with it."
              % feature_path
          )
  
      if domain_info != "domain":
          return getattr(feature, domain_info)
      for domain in schema.string_domain:
          if domain.name == feature.domain:
              return domain
  
      raise ValueError(
          "Feature %s has an unsupported domain %s."
          % (feature_path, domain_info)
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import logging
  from typing import Any, Iterable, List, Mapping, Optional, Set, Text, Tuple, Union
  from tensorflow_data_validation import types
  from tensorflow_data_validation.utils import io_util
  from google.protobuf import descriptor
  from google.protobuf import text_format
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 2 for calling a global function with example usage: get_domain(schema, feature_path) and returns: getattr, domain