def _validate_data_format(data_format):
  """Verify correctness of `data_format` argument."""
  data_format_ = str(data_format).upper()
  if data_format_ in {'NHWC', 'NCHW'}:
    return data_format_
  raise ValueError(
      'Argument data_format="{}" not recognized; must be one of '
      '{{"NHWC", "NCHW"}} (case insensitive).'.format(data_format))