def spec_as_shape(spec, context):
  """Convert a type_spec to a tf shape.

  Args:
    spec: a single specification for tuple_generator_builder
    context: a NQL context

  Returns:
    tensor shape specification, as required by tf.data.Dataset.from_generator
  """
  if spec == str:
    return tf.TensorShape([])
  elif isinstance(spec, int):
    return tf.TensorShape([spec])
  else:
    return tf.TensorShape([context.get_max_id(spec)])
Convert a type_spec to a tf shape.

  Args:
    spec: a single specification for tuple_generator_builder
    context: a NQL context

  Returns:
    tensor shape specification, as required by tf.data.Dataset.from_generator
  
language/nql/nql/dataset.py