code: def store(args: argparse.Namespace):
      """Build a data store with an existing model and a parallel corpus."""
      use_cpu = args.use_cpu
      if not pt.cuda.is_available():
          logger.info("CUDA not available, using cpu")
          use_cpu = True
      device = (
          pt.device("cpu")
          if use_cpu
          else pt.device("cuda", args.device_id)
      )
      logger.info(f"Scoring device: {device}")
  
      model, source_vocabs, target_vocabs = load_model(
          args.model, device=device, dtype=args.dtype
      )
      model.eval()
  
      max_seq_len_source = model.max_supported_len_source
      max_seq_len_target = model.max_supported_len_target
      if args.max_seq_len is not None:
          max_seq_len_source = min(
              args.max_seq_len[0] + C.SPACE_FOR_XOS, max_seq_len_source
          )
          max_seq_len_target = min(
              args.max_seq_len[1] + C.SPACE_FOR_XOS, max_seq_len_target
          )
  
      sources = [args.source] + args.source_factors
      sources = [str(os.path.abspath(source)) for source in sources]
      targets = [args.target] + args.target_factors
      targets = [str(os.path.abspath(target)) for target in targets]
  
      check_condition(
          len(targets) == model.num_target_factors,
          "Number of target inputs/factors provided (%d) does not match number of target factors "
          "required by the model (%d)"
          % (len(targets), model.num_target_factors),
      )
  
      # if state data type is None, use inferred data type
      if args.state_dtype is None:
          args.state_dtype = utils.dtype_to_str(model.dtype)
  
      if not os.path.exists(args.output_dir):
          os.mkdir(args.output_dir)
      elif os.path.isfile(args.output_dir):
          logging.error(f"{args.output_dir} already exists as a file")
  
      generator = DecoderStateGenerator(
          model,
          source_vocabs,
          target_vocabs,
          args.output_dir,
          max_seq_len_source,
          max_seq_len_target,
          args.state_dtype,
          C.KNN_WORD_DATA_STORE_DTYPE,
          device,
      )
      generator.num_states = DecoderStateGenerator.probe_token_count(
          targets[0], max_seq_len_target
      )
      generator.init_store_file(generator.num_states)
      generator.generate_states_and_store(
          sources, targets, args.batch_size, model.eop_id
      )
      generator.save_config()
  
imports: import argparse
  import logging
  import os
  from typing import List, Optional
  import numpy
  import torch
  from .None import arguments
  from .None import constants
  from .None import data_io
  from .None import utils
  from .log import setup_main_logger
  from .model import SockeyeModel, load_model
  from .vocab import Vocab
  from .utils import check_condition
  from .knn import KNNConfig, get_state_store_path, get_word_store_path, get_config_path
label_desc: Use image node_id 1 for calling a global function with example usage: store(args) without return types