def tf_to_py(d):
  """Convert a dict of tf.Variables to Python native types."""
  if not isinstance(d, dict):
    raise NotImplementedError('Only implemented for dictionaries.')
  for k, v in d.items():
    d[k] = v.numpy().item()
  return d