code: def _convert_to_datetime(
      datetime_str: Optional[str],
  ) -> Optional[dt.datetime]:
      """Callback to convert string to datetime given as an iso8601 timestamp."""
      if datetime_str is None:
          return None
  
      try:
          return parse(datetime_str)
      except Exception:
          raise ValueError(
              f"'{datetime_str}' is not a valid iso8601 timestamp"
          )
  
imports: from __future__ import annotations
  import datetime
  import logging
  from typing import Dict, List, Optional
  from dateutil.parser import parse
  from dbt_semantic_interfaces.protocols.semantic_manifest import SemanticManifest
  from dbt_semantic_interfaces.validations.semantic_manifest_validator import SemanticManifestValidator
  from dbt_semantic_interfaces.validations.validator_helpers import SemanticManifestValidationResults
  from metricflow.engine.metricflow_engine import MetricFlowEngine, MetricFlowExplainResult, MetricFlowQueryRequest, MetricFlowQueryResult
  from metricflow.engine.models import Dimension, Metric
  from metricflow.model.semantic_manifest_lookup import SemanticManifestLookup
  from metricflow.protocols.sql_client import SqlClient
  from metricflow.sql.optimizer.optimization_levels import SqlQueryOptimizationLevel
label_desc: Use image node_id 1 for calling a global function with example usage: _convert_to_datetime(datetime_str) and returns: None, parse