code: def _generate_scaffold(
      smiles: str, include_chirality: bool = False
  ) -> Union[str, None]:
      """Compute the Bemis-Murcko scaffold for a SMILES string.
  
      Bemis-Murcko scaffolds are described in DOI: 10.1021/jm9602928.
      They are essentially that part of the molecule consisting of
      rings and the linker atoms between them.
  
      Paramters
      ---------
      smiles: str
          SMILES
      include_chirality: bool, default False
          Whether to include chirality in scaffolds or not.
  
      Returns
      -------
      str
          The MurckScaffold SMILES from the original SMILES
  
      References
      ----------
      .. [1] Bemis, Guy W., and Mark A. Murcko. "The properties of known drugs.
          1. Molecular frameworks." Journal of medicinal chemistry 39.15 (1996): 2887-2893.
  
      Note
      ----
      This function requires RDKit to be installed.
      """
      try:
          from rdkit import Chem
          from rdkit.Chem.Scaffolds.MurckoScaffold import (
              MurckoScaffoldSmiles,
          )
      except ModuleNotFoundError:
          raise ImportError(
              "This function requires RDKit to be installed."
          )
  
      mol = Chem.MolFromSmiles(smiles)
      if mol is None:
          logger.info(
              "Not generating scaffold for smiles %s - invalid smiles string"
              % smiles
          )
          return None
  
      scaffold = MurckoScaffoldSmiles(
          mol=mol, includeChirality=include_chirality
      )
      return scaffold
  
imports: import inspect
  import itertools
  import logging
  import os
  import random
  import tempfile
  from typing import Any, Dict, Iterator, List, Optional, Sequence, Tuple, Union
  import deepchem
  import numpy
  import pandas
  from deepchem.data import Dataset, DiskDataset
  from deepchem.utils import get_print_threshold
label_desc: Use image node_id 2 for calling a global function with example usage: _generate_scaffold(smiles, include_chirality) and returns: scaffold, None