code: def _path(opt, version):
      if version == "2014":
          build_2014(opt)
          buildImage_2014(opt)
      elif version == "2017":
          build_2017(opt)
          buildImage_2017(opt)
      else:
          raise Exception(
              "Unknown version for COCO Captions: %s" % version
          )
  
      dt = opt["datatype"].split(":")[0]
  
      if dt == "train":
          annotation_suffix = "train{}".format(version)
          img_suffix = os.path.join(
              "train{}".format(version),
              "COCO_train{}_".format(version)
              if version == "2014"
              else "",
          )
      elif dt == "valid" or (dt == "test" and version == "2014"):
          annotation_suffix = "val{}".format(version)
          img_suffix = os.path.join(
              "val{}".format(version),
              "COCO_val{}_".format(version)
              if version == "2014"
              else "",
          )
      elif dt == "test":
          annotation_suffix = "None"
          img_suffix = os.path.join(
              "test{}".format(version),
              "COCO_test{}_".format(version)
              if version == "2014"
              else "",
          )
      else:
          raise RuntimeError("Not valid datatype.")
  
      if version == "2017":
          test_info_path = os.path.join(
              opt["datapath"],
              "COCO_2017_Caption",
              "annotations",
              "image_info_test2017.json",
          )
  
          annotation_path = os.path.join(
              opt["datapath"],
              "COCO_2017_Caption",
              "annotations",
              "captions_" + annotation_suffix + ".json",
          )
      else:
          test_info_path = None
          annotation_path = os.path.join(
              opt["datapath"], "COCO_2014_Caption", "dataset_coco.json"
          )
  
      image_path = os.path.join(
          opt["datapath"], "COCO-IMG-{}".format(version), img_suffix
      )
  
      return test_info_path, annotation_path, image_path
  
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from parlai.core.teachers import FixedDialogTeacher
  from parlai.core.image_featurizers import ImageLoader
  from parlai.utils.io import PathManager
  from .build_2014 import build
  from .build_2014 import buildImage
  from .build_2017 import build
  from .build_2017 import buildImage
  import os
  import json
  import random
label_desc: Use image node_id 2 for calling a global function with example usage: _path(opt, version) and returns: test_info_path,  annotation_path,  image_path