def ConvertToUnicode(keys=None):  # pylint: disable=invalid-name
  """Converts to Unicode UTF-8 elements of an example.

  Useful for when TFDS outputs byte arrays. All of the errors of the conversion
  are ignored.

  Args:
    keys: tuple/list of example dimensions to convert.

  Returns:
    Function converting chosen elements of an example to UTF-8.
  """

  @debug_data_pipeline.debug_pipeline
  def _convert_to_unicode_str(stream):
    for example in stream:
      if isinstance(example, (list, tuple)):
        new_example = []
        for i, x in enumerate(example):
          if keys is None or i in keys:
            new_example.append(_to_unicode(x))
          else:
            new_example.append(x)
        output = tuple(new_example)
        yield output
      elif isinstance(example, dict):
        new_example = {}
        for k in example:
          if keys is None or k in keys:
            new_example[k] = _to_unicode(example[k])
          else:
            new_example[k] = example[k]
        yield new_example
      else:
        output = _to_unicode(example)
        yield output

  return _convert_to_unicode_str
Converts to Unicode UTF-8 elements of an example.

  Useful for when TFDS outputs byte arrays. All of the errors of the conversion
  are ignored.

  Args:
    keys: tuple/list of example dimensions to convert.

  Returns:
    Function converting chosen elements of an example to UTF-8.
  
trax/data/tf_inputs.py