def _to_domain(domain):
    if domain.get('ints') is not None:
        return sch.IntDomain(tf.int64)
    if domain.get('floats') is not None:
        return sch.FloatDomain(tf.float32)
    if domain.get('strings') is not None:
        return sch.StringDomain(tf.string)
    if domain.get('bools') is not None:
        return sch.BoolDomain(tf.bool)
    raise ValueError('Unknown domain: {}'.format(domain))
def _from_domain_dict(domain):
  """Translate a JSON domain dict into a Domain."""
  if domain.get('ints') is not None:
    def maybe_to_int(s):
      return int(s) if s is not None else None
    return sch.IntDomain(
        tf.int64,
        maybe_to_int(domain['ints'].get('min')),
        maybe_to_int(domain['ints'].get('max')),
        domain['ints'].get('is_categorical'))
  if domain.get('floats') is not None:
    return sch.FloatDomain(tf.float32)
  if domain.get('strings') is not None:
    return sch.StringDomain(tf.string)
  if domain.get('bools') is not None:
    return sch.BoolDomain(tf.bool)
  raise ValueError('Unknown domain: {}'.format(domain))