class_docstr: WordTensorGenerator generates string tf.Tensor with string
  length similar to a word.
docstr: Create a new WordTensorGenerator
  
  WordTensorGenerator samples word length using Poisson distribution
  with lambda equals to avg_length and generates random bytes for each word.
  
  Args:
    spec: A tf.TensorSpec that describes the output tensor.
    avg_length: An int that represents the average word length.
  
  Raises:
    TypeError: If dtype in spec is not tf.string.
    ValueError: If avg_length is not positive.
docstr_tok: ["Create","a","new","WordTensorGenerator","WordTensorGenerator","samples","word","length","using","Poisson","distribution","with","lambda","equals","to","avg_length","and","generates","random","bytes","for","each","word",".","Args",":","spec",":","A","tf.TensorSpec","that","describes","the","output","tensor",".","avg_length",":","An","int","that","represents","the","average","word","length",".","Raises",":","TypeError",":","If","dtype","in","spec","is","not","tf.string",".","ValueError",":","If","avg_length","is","not","positive","."]
code: def __init__(self, spec, avg_length=5):
      """Create a new WordTensorGenerator
  
      WordTensorGenerator samples word length using Poisson distribution
      with lambda equals to avg_length and generates random bytes for each word.
  
      Args:
        spec: A tf.TensorSpec that describes the output tensor.
        avg_length: An int that represents the average word length.
  
      Raises:
        TypeError: If dtype in spec is not tf.string.
        ValueError: If avg_length is not positive.
      """
      super().__init__(spec)
  
      if spec.dtype is not tf.string:
          raise TypeError(
              "WordTensorGenerator can only generate tf.Tensor with "
              f"dtype in tf.string but found {spec.dtype}."
          )
  
      if avg_length < 1:
          raise ValueError(
              "WordTensorGenerator must have positive avg_length"
              f" but found {avg_length}."
          )
      self._avg_length = avg_length
  
imports: import hashlib
  import numpy
  import tensorflow
  from tests.test_atds_avro.utils.generator.generator_base import Generator
  from tests.test_atds_avro.utils.hash_util import int_to_bytes
label_desc: Use image node_id 1 to create a new WordTensorGenerator object from inherited base classes: TensorGeneratorBase with example: obj = WordTensorGenerator(spec, avg_length)