code: def flatten_dict(dict_, parent_key="", sep="."):
      """Flattens a nested dictionary. Namedtuples within the dictionary are
      converted to dicts.
  
      Adapted from:
      https://github.com/google/seq2seq/blob/master/seq2seq/models/model_base.py
  
      Args:
          dict_ (dict): The dictionary to flatten.
          parent_key (str): A prefix to prepend to each key.
          sep (str): Separator that intervenes between parent and child keys.
              E.g., if `sep` == '.', then `{ "a": { "b": 3 } }` is converted
              into `{ "a.b": 3 }`.
  
      Returns:
          A new flattened `dict`.
      """
      items = []
      for key, value in dict_.items():
          key_ = parent_key + sep + key if parent_key else key
          if isinstance(value, collections.MutableMapping):
              items.extend(flatten_dict(value, key_, sep=sep).items())
          elif isinstance(value, tuple) and hasattr(value, "_asdict"):
              dict_items = collections.OrderedDict(
                  zip(value._fields, value)
              )
              items.extend(
                  flatten_dict(dict_items, key_, sep=sep).items()
              )
          else:
              items.append((key_, value))
      return dict(items)
  
imports: from typing import List, Union
  import inspect
  import funcsigs
  from pydoc import locate
  import copy
  import collections
  import numpy
  import tensorflow
  from texar.tf.hyperparams import HParams
  from texar.tf.utils.dtypes import is_str, is_callable, compat_as_text, _maybe_list_to_array
label_desc: Use image node_id 18 for calling a global function with example usage: flatten_dict(dict_, parent_key, sep) and returns: dict