def get_max_num_context_features(model_config):
  """Returns maximum number of context features from a given config.

  Args:
    model_config: A model config file.

  Returns:
    An integer specifying the max number of context features if the model
      config contains context_config, None otherwise

  """
  meta_architecture = model_config.WhichOneof("model")
  meta_architecture_config = getattr(model_config, meta_architecture)

  if hasattr(meta_architecture_config, "context_config"):
    return meta_architecture_config.context_config.max_num_context_features