code: def _merge_system_configs(host_config, container_config, out_file=None):
      
      out = copy.deepcopy(container_config)
      for k, v in host_config.items():
          if k in set(["galaxy_config"]):
              out[k] = v
          elif k == "resources":
              for pname, resources in v.items():
                  if not isinstance(resources, dict) and pname not in out[k]:
                      out[k][pname] = resources
                  else:
                      for rname, rval in resources.items():
                          if (rname in set(["cores", "jvm_opts", "memory"])
                                or pname in set(["gatk", "mutect"])):
                              if pname not in out[k]:
                                  out[k][pname] = {}
                              out[k][pname][rname] = rval
      # Ensure final file is relocatable by mapping back to reference directory
      if "bcbio_system" in out and ("galaxy_config" not in out or not os.path.isabs(out["galaxy_config"])):
          out["galaxy_config"] = os.path.normpath(os.path.join(os.path.dirname(out["bcbio_system"]),
                                                               os.pardir, "galaxy",
                                                               "universe_wsgi.ini"))
      if out_file:
          with open(out_file, "w") as out_handle:
              yaml.safe_dump(out, out_handle, default_flow_style=False, allow_unicode=False)
      return out
docs: Create a merged system configuration from external and internal specification.