class_docstr: Create a mini-batch from a list of dicts
  
  >>> batch = [('utt1',
  ...           dict(input=[dict(feat='some.ark:123',
  ...                            filetype='mat',
  ...                            name='input1',
  ...                            shape=[100, 80])],
  ...                output=[dict(tokenid='1 2 3 4',
  ...                             name='target1',
  ...                             shape=[4, 31])]]))
  >>> l = LoadInputsAndTargets()
  >>> feat, target = l(batch)
  
  :param: str mode: Specify the task mode, "asr" or "tts"
  :param: str preprocess_conf: The path of a json file for pre-processing
  :param: bool load_input: If False, not to load the input data
  :param: bool load_output: If False, not to load the output data
  :param: bool sort_in_input_length: Sort the mini-batch in descending order
      of the input length
  :param: bool use_speaker_embedding: Used for tts mode only
  :param: bool use_second_target: Used for tts mode only
  :param: dict preprocess_args: Set some optional arguments for preprocessing
  :param: Optional[dict] preprocess_args: Used for tts mode only
class_docstr_tok: ["Create","a","mini-batch","from","a","list","of","dicts",">",">",">","batch","=","[","(","'utt1","'",",","...","dict","(","input=","[","dict","(","feat='some.ark:123","'",",","...","filetype='mat","'",",","...","name='input1","'",",","...","shape=","[","100",",","80","]",")","]",",","...","output=","[","dict","(","tokenid=","'","1","2","3","4","'",",","...","name='target1","'",",","...","shape=","[","4",",","31","]",")","]","]",")",")",">",">",">","l","=","LoadInputsAndTargets","(",")",">",">",">","feat",",","target","=","l","(","batch",")",":","param",":","str","mode",":","Specify","the","task","mode",",","``","asr","''","or","``","tts","''",":","param",":","str","preprocess_conf",":","The","path","of","a","json","file","for","pre-processing",":","param",":","bool","load_input",":","If","False",",","not","to","load","the","input","data",":","param",":","bool","load_output",":","If","False",",","not","to","load","the","output","data",":","param",":","bool","sort_in_input_length",":","Sort","the","mini-batch","in","descending","order","of","the","input","length",":","param",":","bool","use_speaker_embedding",":","Used","for","tts","mode","only",":","param",":","bool","use_second_target",":","Used","for","tts","mode","only",":","param",":","dict","preprocess_args",":","Set","some","optional","arguments","for","preprocessing",":","param",":","Optional","[","dict","]","preprocess_args",":","Used","for","tts","mode","only"]
code: def __init__(
      self,
      mode="asr",
      preprocess_conf=None,
      load_input=True,
      load_output=True,
      sort_in_input_length=True,
      use_speaker_embedding=False,
      use_second_target=False,
      preprocess_args=None,
      keep_all_data_on_mem=False,
  ):
      self._loaders = {}
      if mode not in ["asr", "tts", "mt", "vc"]:
          raise ValueError(
              "Only asr or tts are allowed: mode={}".format(mode)
          )
      if preprocess_conf is not None:
          self.preprocessing = Transformation(preprocess_conf)
          logging.warning(
              "[Experimental feature] Some preprocessing will be done "
              "for the mini-batch creation using {}".format(
                  self.preprocessing
              )
          )
      else:
          # If conf doesn't exist, this function don't touch anything.
          self.preprocessing = None
  
      if use_second_target and use_speaker_embedding and mode == "tts":
          raise ValueError(
              'Choose one of "use_second_target" and '
              '"use_speaker_embedding "'
          )
      if (
          (use_second_target or use_speaker_embedding)
          and mode != "tts"
          and mode != "vc"
      ):
          logging.warning(
              '"use_second_target" and "use_speaker_embedding" is '
              "used only for tts or vc mode"
          )
  
      self.mode = mode
      self.load_output = load_output
      self.load_input = load_input
      self.sort_in_input_length = sort_in_input_length
      self.use_speaker_embedding = use_speaker_embedding
      self.use_second_target = use_second_target
      if preprocess_args is None:
          self.preprocess_args = {}
      else:
          assert isinstance(preprocess_args, dict), type(
              preprocess_args
          )
          self.preprocess_args = dict(preprocess_args)
  
      self.keep_all_data_on_mem = keep_all_data_on_mem
  
imports: import io
  import logging
  import os
  from collections import OrderedDict
  import h5py
  import kaldiio
  import numpy
  import soundfile
  from espnet.transform.transformation import Transformation
label_desc: Use image node_id 1 to create a new LoadInputsAndTargets object from inherited base classes: object with example: obj = LoadInputsAndTargets(mode, preprocess_conf, load_input, load_output, sort_in_input_length, use_speaker_embedding, use_second_target, preprocess_args, keep_all_data_on_mem)