code: def _maybe_get_value_namedtuple_or_dict(
      obj: Any, key: Text, default_value: Any
  ) -> Any:
      if isinstance(obj, Mapping):
          return obj.get(key, default_value)
      if getattr(obj, "_fields", None) is not None:
          return getattr(obj, key, default_value)
      return None
  
file_path: agents/tf_agents/trajectories/policy_step.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  from typing import Any, Mapping, NamedTuple, Optional, Text, Union
  from tf_agents.typing import types
label_desc: Use image node_id 2 for calling a global function with example usage: _maybe_get_value_namedtuple_or_dict(obj, key, default_value) and returns: None, obj, getattr