code: def create_char_to_idx(
      filename: str, max_len: int = 250, smiles_field: str = "smiles"
  ) -> Dict[str, int]:
      """Creates a dictionary with character to index mapping.
  
      Parameters
      ----------
      filename: str
          Name of the file containing the SMILES strings
      max_len: int, default 250
          Maximum allowed length of the SMILES string
      smiles_field: str, default "smiles"
          Field indicating the SMILES strings int the file.
  
      Returns
      -------
      Dict[str, int]
          A dictionary mapping characters to their integer indexes.
  
      """
      smiles_df = pd.read_csv(filename)
      char_set = set()
      for smile in smiles_df[smiles_field]:
          if len(smile) <= max_len:
              char_set.update(set(smile))
  
      unique_char_list = list(char_set)
      unique_char_list += [PAD_TOKEN, OUT_OF_VOCAB_TOKEN]
      char_to_idx = {
          letter: idx for idx, letter in enumerate(unique_char_list)
      }
      return char_to_idx
  
file_path: deepchem/deepchem/feat/molecule_featurizers/smiles_to_seq.py
imports: from typing import Dict, List
  import numpy
  import pandas
  from deepchem.utils.typing import RDKitMol
  from deepchem.feat.base_classes import MolecularFeaturizer
label_desc: Use image node_id 1 for calling a global function with example usage: create_char_to_idx(filename, max_len, smiles_field) and returns: char_to_idx