code: def fmap(
      self, *, function, cls=None, with_names=False, zip_values=None
  ):
      if cls is None:
          # Use same class and settings for mapped dict
          values = self.__class__()
          super(NestedDict, values).__setattr__(
              "value_type", self.value_type
          )
          super(NestedDict, values).__setattr__(
              "overwrite", self.overwrite
          )
          setitem = values.__setitem__
      elif issubclass(cls, list):
          # Special target class list implies flatten
          values = cls()
          setitem = lambda n, v: (
              values.extend(v)
              if isinstance(v, cls)
              else values.append(v)
          )
      elif issubclass(cls, dict):
          # Custom target class
          values = cls()
          setitem = values.__setitem__
      else:
          raise TensorforceError.value(
              name="NestedDict.fmap", argument="cls", value=cls
          )
  
      for name, value in super().items():
          if name == self.__class__._SINGLETON:
              name = None
  
          if isinstance(with_names, str):
              if name is None:
                  full_name = with_names
              else:
                  full_name = "{}/{}".format(with_names, name)
          else:
              assert isinstance(with_names, bool)
              if with_names:
                  if name is None and not isinstance(
                      value, self.value_type
                  ):
                      full_name = True
                  else:
                      full_name = name
              else:
                  full_name = False
  
          if isinstance(zip_values, (tuple, list)):
              zip_value = tuple(xs[name] for xs in zip_values)
          elif isinstance(zip_values, NestedDict):
              zip_value = (zip_values[name],)
          elif zip_values is None:
              zip_value = None
          else:
              raise TensorforceError.type(
                  name="NestedDict.fmap",
                  argument="zip_values",
                  dtype=type(zip_values),
              )
  
          if isinstance(value, self.value_type):
              if with_names:
                  args = (full_name, value)
              else:
                  args = (value,)
              if zip_value is not None:
                  args += zip_value
                  # args += tuple(
                  #     x.singleton() if isinstance(x, NestedDict) else x for x in zip_value
                  # )
              setitem(name, function(*args))
          else:
              setitem(
                  name,
                  value.fmap(
                      function=function,
                      cls=cls,
                      with_names=full_name,
                      zip_values=zip_value,
                  ),
              )
  
      return values
  
imports: from collections import OrderedDict
  from tensorforce import TensorforceError
label_desc: Use image node_id 6 for calling the NestedDict obj's underlying member method code with example usage: obj.fmap() and returns: values