code: def field2slice(field: Optional[str]) -> slice:
      """Convert field string to slice.
  
      Note that field string accepts 1-based integer.
      Examples:
          >>> field2slice("1-")
          slice(0, None, None)
          >>> field2slice("1-3")
          slice(0, 3, None)
          >>> field2slice("-3")
          slice(None, 3, None)
      """
      field = field.strip()
      try:
          if "-" in field:
              # e.g. "2-" or "2-5" or "-7"
              s1, s2 = field.split("-", maxsplit=1)
              if s1.strip() == "":
                  s1 = None
              else:
                  s1 = int(s1)
                  if s1 == 0:
                      raise ValueError("1-based string")
              if s2.strip() == "":
                  s2 = None
              else:
                  s2 = int(s2)
          else:
              # e.g. "2"
              s1 = int(field)
              s2 = s1 + 1
              if s1 == 0:
                  raise ValueError("must be 1 or more value")
      except ValueError:
          raise RuntimeError(
              f"Format error: e.g. '2-', '2-5', or '-5': {field}"
          )
  
      if s1 is None:
          slic = slice(None, s2)
      else:
          # -1 because of 1-based integer following "cut" command
          # e.g "1-3" -> slice(0, 3)
          slic = slice(s1 - 1, s2)
      return slic
  
file_path: espnet/espnet2/bin/tokenize_text.py
imports: import argparse
  import logging
  import sys
  from collections import Counter
  from pathlib import Path
  from typing import List, Optional
  from typeguard import check_argument_types
  from espnet2.text.build_tokenizer import build_tokenizer
  from espnet2.text.cleaner import TextCleaner
  from espnet2.text.phoneme_tokenizer import g2p_choices
  from espnet2.utils.types import str2bool, str_or_none
  from espnet.utils.cli_utils import get_commandline_args
label_desc: Use image node_id 1 for calling a global function with example usage: field2slice(field) and returns: slic