docstr: Creates a stage.
  
  Args:
      single_stage: if true, the .dvc file based stage is created,
          fname is required in that case
      fname: name of the file to use, not used for dvc.yaml files
      validate: if true, the new created stage is checked against the
          stages in the repo. Eg: graph correctness,
          potential overwrites in dvc.yaml file (unless `force=True`).
      force: ignores overwrites in dvc.yaml file
      stage_data: Stage data to create from
          (see create_stage and loads_from for more information)
docstr_tok: ["Creates","a","stage",".","Args",":","single_stage",":","if","true",",","the",".dvc","file","based","stage","is","created",",","fname","is","required","in","that","case","fname",":","name","of","the","file","to","use",",","not","used","for","dvc.yaml","files","validate",":","if","true",",","the","new","created","stage","is","checked","against","the","stages","in","the","repo",".","Eg",":","graph","correctness",",","potential","overwrites","in","dvc.yaml","file","(","unless","`","force=True","`",")",".","force",":","ignores","overwrites","in","dvc.yaml","file","stage_data",":","Stage","data","to","create","from","(","see","create_stage","and","loads_from","for","more","information",")"]
code: def create(
      self,
      single_stage: bool = False,
      validate: bool = True,
      fname: Optional[str] = None,
      force: bool = False,
      **stage_data,
  ) -> Union["Stage", "PipelineStage"]:
      """Creates a stage.
  
      Args:
          single_stage: if true, the .dvc file based stage is created,
              fname is required in that case
          fname: name of the file to use, not used for dvc.yaml files
          validate: if true, the new created stage is checked against the
              stages in the repo. Eg: graph correctness,
              potential overwrites in dvc.yaml file (unless `force=True`).
          force: ignores overwrites in dvc.yaml file
          stage_data: Stage data to create from
              (see create_stage and loads_from for more information)
      """
      from dvc.stage import (
          PipelineStage,
          Stage,
          create_stage,
          restore_fields,
      )
      from dvc.stage.exceptions import InvalidStageName
      from dvc.stage.utils import (
          is_valid_name,
          prepare_file_path,
          validate_kwargs,
      )
  
      stage_data = validate_kwargs(
          single_stage=single_stage, fname=fname, **stage_data
      )
      if single_stage:
          stage_cls = Stage
          path = fname or prepare_file_path(stage_data)
      else:
          path = PROJECT_FILE
          stage_cls = PipelineStage
          stage_name = stage_data["name"]
          if not (stage_name and is_valid_name(stage_name)):
              raise InvalidStageName
  
      stage = create_stage(
          stage_cls, repo=self.repo, path=path, **stage_data
      )
      if validate:
          if not force:
              from dvc.stage.utils import check_stage_exists
  
              check_stage_exists(self.repo, stage, stage.path)
  
          try:
              self.repo.check_graph(stages={stage})
          except OutputDuplicationError as exc:
              # Don't include the stage currently being added.
              exc.stages.remove(stage)
              raise OutputDuplicationError(
                  exc.output, exc.stages
              ) from None
  
      restore_fields(stage)
      return stage
  
imports: import fnmatch
  import typing
  from contextlib import suppress
  from functools import wraps
  from typing import Iterable, List, NamedTuple, Optional, Set, Tuple, Union
  from dvc.exceptions import NoOutputOrStageError, OutputDuplicationError, OutputNotFoundError
  from dvc.log import logger
  from dvc.repo import lock_repo
  from dvc.ui import ui
  from dvc.utils import as_posix, parse_target
label_desc: Use image node_id 4 for calling the StageLoad obj's underlying member method code with example usage: obj.create(single_stage, validate, fname, force) and returns: stage