code: def from_smiles(
      smiles: str, with_hydrogen: bool = False, kekulize: bool = False
  ) -> "torch_geometric.data.Data":
      r"""Converts a SMILES string to a :class:`torch_geometric.data.Data`
      instance.
  
      Args:
          smiles (str): The SMILES string.
          with_hydrogen (bool, optional): If set to :obj:`True`, will store
              hydrogens in the molecule graph. (default: :obj:`False`)
          kekulize (bool, optional): If set to :obj:`True`, converts aromatic
              bonds to single/double bonds. (default: :obj:`False`)
      """
      from rdkit import Chem, RDLogger
  
      from torch_geometric.data import Data
  
      RDLogger.DisableLog("rdApp.*")
  
      mol = Chem.MolFromSmiles(smiles)
  
      if mol is None:
          mol = Chem.MolFromSmiles("")
      if with_hydrogen:
          mol = Chem.AddHs(mol)
      if kekulize:
          Chem.Kekulize(mol)
  
      xs: List[List[int]] = []
      for atom in mol.GetAtoms():
          row: List[int] = []
          row.append(x_map["atomic_num"].index(atom.GetAtomicNum()))
          row.append(x_map["chirality"].index(str(atom.GetChiralTag())))
          row.append(x_map["degree"].index(atom.GetTotalDegree()))
          row.append(
              x_map["formal_charge"].index(atom.GetFormalCharge())
          )
          row.append(x_map["num_hs"].index(atom.GetTotalNumHs()))
          row.append(
              x_map["num_radical_electrons"].index(
                  atom.GetNumRadicalElectrons()
              )
          )
          row.append(
              x_map["hybridization"].index(str(atom.GetHybridization()))
          )
          row.append(x_map["is_aromatic"].index(atom.GetIsAromatic()))
          row.append(x_map["is_in_ring"].index(atom.IsInRing()))
          xs.append(row)
  
      x = torch.tensor(xs, dtype=torch.long).view(-1, 9)
  
      edge_indices, edge_attrs = [], []
      for bond in mol.GetBonds():
          i = bond.GetBeginAtomIdx()
          j = bond.GetEndAtomIdx()
  
          e = []
          e.append(e_map["bond_type"].index(str(bond.GetBondType())))
          e.append(e_map["stereo"].index(str(bond.GetStereo())))
          e.append(e_map["is_conjugated"].index(bond.GetIsConjugated()))
  
          edge_indices += [[i, j], [j, i]]
          edge_attrs += [e, e]
  
      edge_index = torch.tensor(edge_indices)
      edge_index = edge_index.t().to(torch.long).view(2, -1)
      edge_attr = torch.tensor(edge_attrs, dtype=torch.long).view(-1, 3)
  
      if edge_index.numel() > 0:  # Sort indices.
          perm = (edge_index[0] * x.size(0) + edge_index[1]).argsort()
          edge_index, edge_attr = edge_index[:, perm], edge_attr[perm]
  
      return Data(
          x=x, edge_index=edge_index, edge_attr=edge_attr, smiles=smiles
      )
  
imports: from typing import Any, Dict, List
  import torch
  import torch_geometric
label_desc: Use image node_id 1 for calling a global function with example usage: from_smiles(smiles, with_hydrogen, kekulize) and returns: Data