code: def train_human(opt):
      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,
          mask_dir=opt.mask_dir,
          smpl_type=opt.smpl_type,
      )
      if opt.geo_threshold < 0:
          can_bones = []
          bones = []
          for i in range(len(train_scene.captures)):
              bones.append(
                  np.linalg.norm(
                      train_scene.smpls[i]["joints_3d"][3]
                      - train_scene.smpls[i]["joints_3d"][0]
                  )
              )
              can_bones.append(
                  np.linalg.norm(
                      train_scene.smpls[i]["static_joints_3d"][3]
                      - train_scene.smpls[i]["static_joints_3d"][0]
                  )
              )
          opt.geo_threshold = np.mean(bones)
      poses = np.stack([item["pose"] for item in train_scene.smpls])
      betas = np.stack([item["betas"] for item in train_scene.smpls])
      raw_alignments = np.load(
          os.path.join(opt.scene_dir, "alignments.npy"),
          allow_pickle=True,
      ).item()
      alignments = np.stack(
          [
              raw_alignments[os.path.basename(cap.image_path)]
              for cap in train_scene.captures
          ]
      )
      alignments2 = np.stack([np.eye(4)] * alignments.shape[0])
      alignments2[..., :3] = alignments
      net = human_nerf.HumanNeRF(
          opt,
          poses.copy(),
          betas.copy(),
          alignments2.copy(),
          scale=train_scene.scale,
      )
      device = next(net.parameters()).device
      train_scene.read_data_to_ram(data_list=["image", "depth"])
      utils.add_border_mask(train_scene, iterations=opt.dilation)
      utils.add_pytorch3d_cache(train_scene, device)
      utils.move_smpls_to_torch(train_scene, device)
  
      train_dset = human_rays.HumanRayDataset(
          opt, train_scene, "train", train_split
      )
      val_dset = human_rays.HumanRayDataset(
          opt,
          train_scene,
          "val",
          val_split,
          near_far_cache=train_dset.near_far_cache,
      )
  
      train_loader = DataLoader(
          train_dset,
          batch_size=1,
          shuffle=True,
          num_workers=4,
          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,
      )
  
      assert opt.bkg_lr == 0
      if opt.train_mode == "smpl_only":
          assert opt.offset_scale == 0
          optim_list = [
              {"params": net.poses, "lr": opt.learning_rate},
              {
                  "params": net.coarse_human_net.parameters(),
                  "lr": opt.learning_rate,
              },
          ]
      elif opt.train_mode == "smpl_and_offset":
          optim_list = [
              {"params": net.poses, "lr": opt.smpl_lr},
              {
                  "params": net.coarse_human_net.parameters(),
                  "lr": opt.learning_rate,
              },
              {
                  "params": net.offset_nets.parameters(),
                  "lr": opt.learning_rate,
              },
          ]
      optim = torch.optim.Adam(optim_list)
  
      trainer = human_nerf_trainer.HumanNeRFTrainer(
          opt,
          net,
          optim,
          train_loader,
          val_loader,
          train_dset,
          val_dset,
          interval_comp=opt.geo_threshold / np.mean(can_bones),
      )
  
      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 2 for calling a global function with example usage: train_human(opt) without return types