code: def _translate(data):
      if isinstance(data, dict):
          if "()" in data:
              ty = data.pop("()")
              args = get_args(data)
              kwargs = valmap(_translate, data)
  
              return {
                  "__kind__": "instance",
                  "class": ty,
                  "args": args,
                  "kwargs": kwargs,
              }
  
          if "!" in data:
              ty = data.pop("!")
              kwargs = valmap(_translate, data)
  
              return {
                  "__kind__": "stateful",
                  "class": ty,
                  "kwargs": kwargs,
              }
  
          if "#" in data:
              return {
                  "__kind__": "type",
                  "class": data.pop("#"),
              }
  
          return valmap(_translate, data)
  
      if isinstance(data, list):
          return list(map(_translate, data))
  
      return data
  
file_path: gluonts/src/gluonts/core/serde/flat.py
imports: from collections import defaultdict
  from itertools import count
  from typing import Any
  from toolz.dicttoolz import keymap, valmap
  from ._base import encode, Kind, decode
label_desc: Use image node_id 6 for calling a global function with example usage: _translate(data) and returns: data, valmap, list, dict, dict, dict