class_docstr: A wrapper around the output of the tf.Transform.
docstr: Like vocabulary_file_by_name, but returns the size of vocabulary.
docstr_tok: ["Like","vocabulary_file_by_name",",","but","returns","the","size","of","vocabulary","."]
code: def vocabulary_size_by_name(self, vocab_filename: str) -> int:
      """Like vocabulary_file_by_name, but returns the size of vocabulary."""
      vocab_size_from_annotations = (
          self._vocabulary_size_from_annotations(vocab_filename)
      )
      if vocab_size_from_annotations is not None:
          return vocab_size_from_annotations
  
      vocab_path = self.vocabulary_file_by_name(vocab_filename)
      if not vocab_path:
          raise ValueError(
              "Could not compute vocabulary size for {}, does not exist".format(
                  vocab_filename
              )
          )
      elif vocab_path.endswith("tfrecord.gz"):
          dataset = tf.data.TFRecordDataset(
              vocab_path, compression_type="GZIP"
          )
  
          def reduce_fn(accum, elem):
              return (
                  tf.size(
                      elem, out_type=tf.int64, name="vocabulary_size"
                  )
                  + accum
              )
  
          return _get_tensor_value(
              dataset.batch(tf.int32.max).reduce(
                  tf.constant(0, tf.int64), reduce_fn
              )
          )
      else:
          with tf.io.gfile.GFile(vocab_path, "rb") as f:
              return sum(1 for _ in f)
  
imports: import json
  import os
  from typing import Any, Dict, List, Mapping, Optional
  import numpy
  import tensorflow
  from tensorflow_transform import common
  from tensorflow_transform import common_types
  from tensorflow_transform import graph_tools
  from tensorflow_transform.analyzers import sanitized_vocab_filename
  from tensorflow_transform.keras_lib import tf_keras
  from tensorflow_transform.saved import saved_transform_io
  from tensorflow_transform.saved import saved_transform_io_v2
  from tensorflow_transform.tf_metadata import dataset_metadata
  from tensorflow_transform.tf_metadata import metadata_io
  from tensorflow_transform.tf_metadata import schema_utils
  from tensorflow.python.framework import ops
  from tensorflow.tools.docs import doc_controls
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 10 for calling the TFTransformOutput obj's underlying member method code with example usage: obj.vocabulary_size_by_name(vocab_filename) and returns: vocab_size_from_annotations, _get_tensor_value, unknown, sum