class_docstr: Simple translation for GluonTS Datasets.
  
  A given translator transforms an input dictionary (data-entry) into an
  output dictionary.
  
  Basic usage::
  
      >>> tl = Translator.parse(x="a[0]")
      >>> data = {"a": [1, 2, 3]}
      >>> assert tl(data)["x"] == 1
  
  A translator first copies all input fields into a new dictionary, before
  applying the translations. Thus, an empty `Translator` acts like the
  identity function for dictionaries:
  
      >>> identity = Translator()
      >>> data = {"a": 1, "b": 2, "c": 3}
      >>> assert identity(data) == data
  
  Using ``Translator.parse(...)```, one can define expressions to be applied
  to the input data. For example, ``Translator.parse(x="y")`` will write the
  the value of `y` to the `x` column in the output.
  
  These right-hand expressions support indexing (e.g. ``y[1]``), attribute
  access (e.g. ``x.T``) and method invocation (e.g. ``y.transpose(1, 0)``).
class_docstr_tok: ["Simple","translation","for","GluonTS","Datasets",".","A","given","translator","transforms","an","input","dictionary","(","data-entry",")","into","an","output","dictionary",".","Basic","usage",":",":",">",">",">","tl","=","Translator.parse","(","x=","''","a","[","0","]","''",")",">",">",">","data","=","{","``","a","''",":","[","1",",","2",",","3","]","}",">",">",">","assert","tl","(","data",")","[","``","x","''","]","==","1","A","translator","first","copies","all","input","fields","into","a","new","dictionary",",","before","applying","the","translations",".","Thus",",","an","empty","`","Translator","`","acts","like","the","identity","function","for","dictionaries",":",">",">",">","identity","=","Translator","(",")",">",">",">","data","=","{","``","a","''",":","1",",","``","b","''",":","2",",","``","c","''",":","3","}",">",">",">","assert","identity","(","data",")","==","data","Using","``","Translator.parse","(","...",")","``","`",",","one","can","define","expressions","to","be","applied","to","the","input","data",".","For","example",",","``","Translator.parse","(","x=","''","y","''",")","``","will","write","the","the","value","of","`","y","`","to","the","`","x","`","column","in","the","output",".","These","right-hand","expressions","support","indexing","(","e.g",".","``","y","[","1","]","``",")",",","attribute","access","(","e.g",".","``","x.T","``",")","and","method","invocation","(","e.g",".","``","y.transpose","(","1",",","0",")","``",")","."]
code: def get_fields(self):
      return chain.from_iterable(
          op.fields() for op in self.fields.values()
      )
  
imports: import re
  from dataclasses import dataclass, InitVar, field
  from itertools import chain
  from typing import Any, Dict, List, Union, Optional, ClassVar
  import numpy
  from toolz import valfilter, valmap
label_desc: Use image node_id 3 for calling the Translator obj's underlying member method code with example usage: obj.get_fields() and returns: chain