docstr: Initializes the instance.
  
  Args:
      subparsers (`Optional[_SubParsersAction]`):
          The parent subparsers this command will create its parser on.
      args (`Optional[Namespace]`, defaults to `None`):
          The parsed arguments that are going to be use in self.run().
      command (`Optional[CommandInfo]`, defaults to `None`):
          The command info for this instance. This can be used to set the class attribute `COMMAND`.
      from_defaults_factory (`bool`, defaults to `False`):
          When setting the parser defaults, we create a second instance of self. By setting
          `from_defaults_factory=True`, we do not do unnecessary actions for setting the defaults, such as
          creating a parser.
docstr_tok: ["Initializes","the","instance",".","Args",":","subparsers","(","`","Optional","[","_SubParsersAction","]","`",")",":","The","parent","subparsers","this","command","will","create","its","parser","on",".","args","(","`","Optional","[","Namespace","]","`",",","defaults","to","`","None","`",")",":","The","parsed","arguments","that","are","going","to","be","use","in","self.run","(",")",".","command","(","`","Optional","[","CommandInfo","]","`",",","defaults","to","`","None","`",")",":","The","command","info","for","this","instance",".","This","can","be","used","to","set","the","class","attribute","`","COMMAND","`",".","from_defaults_factory","(","`","bool","`",",","defaults","to","`","False","`",")",":","When","setting","the","parser","defaults",",","we","create","a","second","instance","of","self",".","By","setting","`","from_defaults_factory=True","`",",","we","do","not","do","unnecessary","actions","for","setting","the","defaults",",","such","as","creating","a","parser","."]
code: def __init__(
      self,
      subparsers: Optional["_SubParsersAction"],
      args: Optional["Namespace"] = None,
      command: Optional[CommandInfo] = None,
      from_defaults_factory: bool = False,
      parser: Optional["ArgumentParser"] = None,
  ):
      """
      Initializes the instance.
  
      Args:
          subparsers (`Optional[_SubParsersAction]`):
              The parent subparsers this command will create its parser on.
          args (`Optional[Namespace]`, defaults to `None`):
              The parsed arguments that are going to be use in self.run().
          command (`Optional[CommandInfo]`, defaults to `None`):
              The command info for this instance. This can be used to set the class attribute `COMMAND`.
          from_defaults_factory (`bool`, defaults to `False`):
              When setting the parser defaults, we create a second instance of self. By setting
              `from_defaults_factory=True`, we do not do unnecessary actions for setting the defaults, such as
              creating a parser.
      """
      # For leaf commands, it is redundant to define the `COMMAND` attribute since it was already defined in the
      # parent command, by doing this we pass this information between parent and child command.
      if command is not None:
          self.COMMAND = command
  
      if from_defaults_factory:
          if parser is None:
              raise ValueError(
                  "The instance of the original parser must be passed when creating a defaults factory, command: "
                  f"{self}."
              )
          self.parser = parser
          self.subparsers = subparsers
      else:
          if subparsers is None:
              raise ValueError(
                  f"A subparsers instance is needed when from_defaults_factory=False, command: {self}."
              )
          self.parser = subparsers.add_parser(
              self.COMMAND.name, help=self.COMMAND.help
          )
          self.parse_args(self.parser)
  
          def defaults_factory(args):
              return self.__class__(
                  self.subparsers,
                  args,
                  command=self.COMMAND,
                  from_defaults_factory=True,
                  parser=self.parser,
              )
  
          self.parser.set_defaults(func=defaults_factory)
  
          for subcommand in self.SUBCOMMANDS:
              if not isinstance(subcommand, CommandInfo):
                  raise ValueError(
                      f"Subcommands must be instances of CommandInfo, but got {type(subcommand)} here."
                  )
              self.register_subcommand(subcommand)
  
      self.args = args
  
file_path: optimum/optimum/commands/base.py
imports: from abc import ABC
  from argparse import ArgumentParser, RawTextHelpFormatter
  from dataclasses import dataclass
  from typing import TYPE_CHECKING, Optional, Tuple, Type
label_desc: Use image node_id 1 to create a new BaseOptimumCLICommand object from inherited base classes: ABC with example: obj = BaseOptimumCLICommand(subparsers, args, command, from_defaults_factory, parser)