in tensorflow/src/main/scala/magnolify/tensorflow/ExampleType.scala [43:56]
implicit def apply[T: ExampleField]: ExampleType[T] = ExampleType(CaseMapper.identity)
def apply[T](cm: CaseMapper)(implicit f: ExampleField[T]): ExampleType[T] = f match {
case r: ExampleField.Record[_] =>
new ExampleType[T] {
@transient override lazy val schema: Schema = r.schema(cm)
override def from(v: Map[String, Feature]): T =
r.get(v, null)(cm)
override def to(v: T): Example.Builder =
Example.newBuilder().setFeatures(r.put(Features.newBuilder(), null, v)(cm))
}
case _ =>
throw new IllegalArgumentException(s"ExampleType can only be created from Record. Got $f")
}