code: def _hydra_main(cfg: FairseqConfig, **kwargs) -> float:
      add_defaults(cfg)
  
      if cfg.common.reset_logging:
          reset_logging()  # Hydra hijacks logging, fix that
      else:
          # check if directly called or called through hydra_main
          if HydraConfig.initialized():
              with open_dict(cfg):
                  # make hydra logging work with ddp (see # see https://github.com/facebookresearch/hydra/issues/1126)
                  cfg.job_logging_cfg = OmegaConf.to_container(
                      HydraConfig.get().job_logging, resolve=True
                  )
  
      with omegaconf_no_object_check():
          cfg = OmegaConf.create(
              OmegaConf.to_container(
                  cfg, resolve=True, enum_to_str=True
              )
          )
      OmegaConf.set_struct(cfg, True)
  
      try:
          if cfg.common.profile:
              with torch.cuda.profiler.profile():
                  with torch.autograd.profiler.emit_nvtx():
                      distributed_utils.call_main(
                          cfg, pre_main, **kwargs
                      )
          else:
              distributed_utils.call_main(cfg, pre_main, **kwargs)
      except BaseException as e:
          if not cfg.common.suppress_crashes:
              raise
          else:
              logger.error("Crashed! " + str(e))
  
      # get best val and return - useful for sweepers
      try:
          best_val = metrics.get_smoothed_value(
              "valid", cfg.checkpoint.best_checkpoint_metric
          )
      except:
          best_val = None
  
      if best_val is None:
          best_val = float("inf")
  
      return best_val
  
file_path: fairseq/fairseq_cli/hydra_train.py
imports: import logging
  import os
  import hydra
  import torch
  from hydra.core.hydra_config import HydraConfig
  from omegaconf import OmegaConf, open_dict
  from fairseq import distributed_utils, metrics
  from fairseq.dataclass.configs import FairseqConfig
  from fairseq.dataclass.initialize import add_defaults, hydra_init
  from fairseq.dataclass.utils import omegaconf_no_object_check
  from fairseq.utils import reset_logging
  from fairseq_cli.train import main
label_desc: Use image node_id 2 for calling a global function with example usage: _hydra_main(cfg) and returns: best_val