def _vocabulary_size_from_annotations(self,
                                        vocab_filename: str) -> Optional[int]:
    """If vocabulary size is present in annotations return it, else None."""
    if not common.IS_ANNOTATIONS_PB_AVAILABLE:
      return None

    try:
      schema = self.transformed_metadata.schema
    except IOError:
      return None

    from tensorflow_transform import annotations_pb2  # pylint: disable=g-import-not-at-top
    for annotation in schema.annotation.extra_metadata:
      message = annotations_pb2.VocabularyMetadata()
      annotation.Unpack(message)
      # Check message.filtered_vocabulary_size is not 0 for backwards
      # compatibility.
      if (message.file_name == vocab_filename and
          message.filtered_vocabulary_size != 0):
        return message.filtered_vocabulary_size

    return None
If vocabulary size is present in annotations return it, else None.
tensorflow_transform/output_wrapper.py