code: def create(
      ctx,
      pathspec,
      mode=None,
      type=None,
      options=None,
      timeout=None,
      component_file=None,
      data_file=None,
      render_error_card=False,
      card_uuid=None,
      delete_input_files=None,
      id=None,
  ):
      card_id = id
      rendered_info = None  # Variable holding all the information which will be rendered
      error_stack_trace = (
          None  # Variable which will keep a track of error
      )
  
      if len(pathspec.split("/")) != 3:
          raise CommandException(
              msg="Expecting pathspec of form <runid>/<stepname>/<taskid>"
          )
      flowname = ctx.obj.flow.name
      full_pathspec = "/".join([flowname, pathspec])
  
      graph_dict, _ = ctx.obj.graph.output_steps()
  
      if card_uuid is None:
          card_uuid = str(uuid.uuid4()).replace("-", "")
  
      # Components are rendered in a Step and added via `current.card.append` are added here.
      component_arr = []
      if component_file is not None:
          with open(component_file, "r") as f:
              component_arr = json.load(f)
          # Component data used in card runtime is passed in as temporary files which can be deleted after use
          if delete_input_files:
              os.remove(component_file)
  
      # Load data to be refreshed for runtime cards
      data = {}
      if data_file is not None:
          with open(data_file, "r") as f:
              data = json.load(f)
          # data is passed in as temporary files which can be deleted after use
          if delete_input_files:
              os.remove(data_file)
  
      task = Task(full_pathspec)
      from metaflow.plugins import CARDS
      from metaflow.plugins.cards.exception import (
          CARD_ID_PATTERN,
          TYPE_CHECK_REGEX,
      )
      from metaflow.cards import ErrorCard
  
      error_card = ErrorCard
      filtered_cards = [
          CardClass for CardClass in CARDS if CardClass.type == type
      ]
      card_datastore = CardDatastore(
          ctx.obj.flow_datastore, pathspec=full_pathspec
      )
  
      if len(filtered_cards) == 0 or type is None:
          if render_error_card:
              error_stack_trace = str(CardClassFoundException(type))
          else:
              raise CardClassFoundException(type)
  
      if len(filtered_cards) > 0:
          filtered_card = filtered_cards[0]
          ctx.obj.echo(
              "Creating new card of type %s with timeout %s"
              % (filtered_card.type, timeout),
              fg="green",
          )
          # If the card is Instantiatable then
          # first instantiate; If instantiation has a TypeError
          # then check for render_error_card and accordingly
          # store the exception as a string or raise the exception
          try:
              if options is not None:
                  mf_card = filtered_card(
                      options=options,
                      components=component_arr,
                      graph=graph_dict,
                  )
              else:
                  mf_card = filtered_card(
                      components=component_arr, graph=graph_dict
                  )
          except TypeError as e:
              if render_error_card:
                  mf_card = None
                  error_stack_trace = str(
                      IncorrectCardArgsException(type, options)
                  )
              else:
                  raise IncorrectCardArgsException(type, options)
  
          rendered_content = None
          if mf_card:
              try:
                  rendered_info = update_card(
                      mf_card, mode, task, data, timeout_value=timeout
                  )
                  rendered_content = rendered_info.data
              except:
                  rendered_info = CardRenderInfo(
                      mode=mode,
                      is_implemented=True,
                      data=None,
                      timed_out=False,
                      timeout_stack_trace=None,
                  )
                  if render_error_card:
                      error_stack_trace = str(
                          UnrenderableCardException(type, options)
                      )
                  else:
                      raise UnrenderableCardException(type, options)
  
      # In the entire card rendering process, there are a few cases we want to handle:
      # - [mode == "render"]
      #   1. Card is rendered successfully (We store it in the datastore as a HTML file)
      #   2. Card is not rendered successfully and we have --save-error-card flag set to True
      #      (We store it in the datastore as a HTML file with stack trace)
      #   3. Card render timed-out and we have --save-error-card flag set to True
      #      (We store it in the datastore as a HTML file with stack trace)
      #   4. `render` returns nothing and we have --save-error-card flag set to True.
      #       (We store it in the datastore as a HTML file with some message saying you returned nothing)
      # - [mode == "render_runtime"]
      #   1. Card is rendered successfully (We store it in the datastore as a HTML file)
      #   2. `render_runtime` is not implemented but gets called and we have --save-error-card flag set to True.
      #       (We store it in the datastore as a HTML file with some message saying the card should not be a runtime card if this method is not Implemented)
      #   3. `render_runtime` is implemented and raises an exception and we have --save-error-card flag set to True.
      #       (We store it in the datastore as a HTML file with stack trace)
      #   4. `render_runtime` is implemented but returns nothing and we have --save-error-card flag set to True.
      #       (We store it in the datastore as a HTML file with some message saying you returned nothing)
      #   5. `render_runtime` is implemented but times out and we have --save-error-card flag set to True.
      #       (We store it in the datastore as a HTML file with stack trace)
      # - [mode == "refresh"]
      #   1. Data update is created successfully (We store it in the datastore as a JSON file)
      #   2. `refresh` is not implemented. (We do nothing. Don't store anything.)
      #   3. `refresh` is implemented but it raises an exception. (We do nothing. Don't store anything.)
      #   4. `refresh` is implemented but it times out. (We do nothing. Don't store anything.)
  
      if error_stack_trace is not None and mode != "refresh":
          rendered_content = error_card().render(
              task, stack_trace=error_stack_trace
          )
  
      if (
          rendered_info.is_implemented
          and rendered_info.timed_out
          and mode != "refresh"
          and render_error_card
      ):
          timeout_stack_trace = (
              "\nCard rendering timed out after %s seconds. "
              "To increase the timeout duration for card rendering, please set the `timeout` parameter in the @card decorator. "
              "\nStack Trace : \n%s"
          ) % (timeout, rendered_info.timeout_stack_trace)
          rendered_content = error_card().render(
              task,
              stack_trace=timeout_stack_trace,
          )
      elif (
          rendered_info.is_implemented
          and rendered_info.data is None
          and render_error_card
          and mode != "refresh"
      ):
          rendered_content = error_card().render(
              task,
              stack_trace="No information rendered from card of type %s"
              % type,
          )
      elif (
          not rendered_info.is_implemented
          and render_error_card
          and mode == "render_runtime"
      ):
          message = (
              "Card of type %s is a runtime time card with no `render_runtime` implemented. "
              "Please implement `render_runtime` method to allow rendering this card at runtime."
          ) % type
          rendered_content = error_card().render(
              task, stack_trace=message
          )
  
      # todo : should we save native type for error card or error type ?
      if (
          type is not None
          and re.match(CARD_ID_PATTERN, type) is not None
      ):
          save_type = type
      else:
          save_type = "error"
  
      # If card_id is doesn't match regex pattern then we will set it as None
      if (
          card_id is not None
          and re.match(CARD_ID_PATTERN, card_id) is None
      ):
          ctx.obj.echo(
              "`--id=%s` doesn't match REGEX pattern. `--id` will be set to `None`. Please create `--id` of pattern %s."
              % (card_id, TYPE_CHECK_REGEX),
              fg="red",
          )
          card_id = None
  
      if rendered_content is not None:
          if mode == "refresh":
              card_datastore.save_data(
                  card_uuid,
                  save_type,
                  rendered_content,
                  card_id=card_id,
              )
              ctx.obj.echo("Data updated", fg="green")
          else:
              card_info = card_datastore.save_card(
                  card_uuid,
                  save_type,
                  rendered_content,
                  card_id=card_id,
              )
              ctx.obj.echo(
                  "Card created with type: %s and hash: %s"
                  % (
                      card_info.type,
                      card_info.hash[:NUM_SHORT_HASH_CHARS],
                  ),
                  fg="green",
              )
  
imports: from metaflow.client import Task
  from metaflow import JSONType, namespace
  from metaflow.util import resolve_identity
  from metaflow.exception import CommandException, MetaflowNotFound, MetaflowNamespaceMismatch
  import webbrowser
  import re
  from metaflow._vendor import click
  import os
  import json
  import uuid
  import signal
  import random
  from contextlib import contextmanager
  from functools import wraps
  from metaflow.exception import MetaflowNamespaceMismatch
  from .card_datastore import CardDatastore, NUM_SHORT_HASH_CHARS
  from .exception import CardClassFoundException, IncorrectCardArgsException, UnrenderableCardException, CardNotPresentException, TaskNotFoundException
  import traceback
  from collections import namedtuple
  from .card_resolver import resolve_paths_from_task, resumed_info
label_desc: Use image node_id 13 for calling a global function with example usage: create(ctx, pathspec, mode, type, options, timeout, component_file, data_file, render_error_card, card_uuid, delete_input_files, id) without return types