code: def import_chart(
      slc_to_import: Slice,
      slc_to_override: Optional[Slice],
      import_time: Optional[int] = None,
  ) -> int:
      """Inserts or overrides slc in the database.
  
      remote_id and import_time fields in params_dict are set to track the
      slice origin and ensure correct overrides for multiple imports.
      Slice.perm is used to find the datasources and connect them.
  
      :param Slice slc_to_import: Slice object to import
      :param Slice slc_to_override: Slice to replace, id matches remote_id
      :returns: The resulting id for the imported slice
      :rtype: int
      """
      session = db.session
      make_transient(slc_to_import)
      slc_to_import.dashboards = []
      slc_to_import.alter_params(
          remote_id=slc_to_import.id, import_time=import_time
      )
  
      slc_to_import = slc_to_import.copy()
      slc_to_import.reset_ownership()
      params = slc_to_import.params_dict
      datasource = SqlaTable.get_datasource_by_name(
          session=session,
          datasource_name=params["datasource_name"],
          database_name=params["database_name"],
          schema=params["schema"],
      )
      slc_to_import.datasource_id = datasource.id  # type: ignore
      if slc_to_override:
          slc_to_override.override(slc_to_import)
          session.flush()
          return slc_to_override.id
      session.add(slc_to_import)
      logger.info("Final slice: %s", str(slc_to_import.to_json()))
      session.flush()
      return slc_to_import.id
  
imports: import json
  import logging
  import time
  from copy import copy
  from datetime import datetime
  from typing import Any, Optional
  from flask_babel import lazy_gettext
  from sqlalchemy.orm import make_transient, Session
  from superset import db
  from superset.commands.base import BaseCommand
  from superset.commands.dataset.importers.v0 import import_dataset
  from superset.connectors.sqla.models import SqlaTable, SqlMetric, TableColumn
  from superset.exceptions import DashboardImportException
  from superset.models.dashboard import Dashboard
  from superset.models.slice import Slice
  from superset.utils.dashboard_filter_scopes_converter import convert_filter_scopes, copy_filter_scopes
label_desc: Use image node_id 1 for calling a global function with example usage: import_chart(slc_to_import, slc_to_override, import_time) and returns: slc_to_import, slc_to_override