code: def train_background(opt):
      assert opt.bkg_rays_ratio == 1
      coarse_net, fine_net = vanilla.build_nerf(opt)
      coarse_net = nn.DataParallel(coarse_net)
      if fine_net is not None:
          fine_net = nn.DataParallel(fine_net)
      train_split, val_split, _ = neuman_helper.create_split_files(
          opt.scene_dir
      )
      train_scene = neuman_helper.NeuManReader.read_scene(
          opt.scene_dir,
          tgt_size=opt.tgt_size,
          normalize=opt.normalize,
          bkg_range_scale=opt.bkg_range_scale,
          human_range_scale=opt.human_range_scale,
      )
      train_scene.read_data_to_ram(data_list=["image", "depth"])
      utils.add_border_mask(train_scene, iterations=opt.dilation)
      train_dset = background_rays.BackgroundRayDataset(
          opt, train_scene, "train", train_split
      )
      val_dset = background_rays.BackgroundRayDataset(
          opt, train_scene, "val", val_split
      )
  
      train_loader = DataLoader(
          train_dset,
          batch_size=1,
          shuffle=True,
          num_workers=5,
          worker_init_fn=utils.worker_init_fn,
      )
      val_loader = DataLoader(
          val_dset,
          batch_size=1,
          shuffle=True,
          num_workers=0,
          worker_init_fn=utils.worker_init_fn,
      )
  
      optim_list = [
          {"params": coarse_net.parameters(), "lr": opt.learning_rate},
          {"params": fine_net.parameters(), "lr": opt.learning_rate},
      ]
      optim = torch.optim.Adam(optim_list, betas=(0.9, 0.999))
  
      trainer = vanilla_nerf_trainer.NeRFTrainer(
          opt,
          coarse_net,
          optim,
          None,
          train_loader,
          val_loader,
          train_dset,
          val_dset,
          fine_net=fine_net,
          penalize_empty_space=opt.penalize_empty_space,
      )
  
      trainer.train()
  
file_path: ml-neuman/train.py
imports: import argparse
  import os
  import math
  import numpy
  import torch
  import torch.nn
  from torch.utils.data import DataLoader
  from data_io import neuman_helper
  from utils import utils
  from datasets import background_rays, human_rays
  from options.options import str2bool
  from options import options
  from models import vanilla, human_nerf
  from trainers import vanilla_nerf_trainer, human_nerf_trainer
label_desc: Use image node_id 1 for calling a global function with example usage: train_background(opt) without return types