code: def copy_to_parser(self, parser, parsed_args):
      def cast_to_bool_int(value, strip=False):
          a_strip_v = value if not strip else str(value).lower().strip()
          if a_strip_v == "false" or not a_strip_v:
              return False
          elif a_strip_v == "true":
              return True
          else:
              # first try to cast to integer
              try:
                  return int(a_strip_v)
              except (ValueError, TypeError):
                  return None
  
      # Change to argparse prefix only
      prefix = (
          self._prefix_args
          if Session.check_min_api_version("2.9")
          else ""
      )
      task_arguments = dict(
          [
              (k[len(prefix) :], v)
              for k, v in self._task.get_parameters().items()
              if k.startswith(prefix)
              and self._exclude_parser_args.get(k[len(prefix) :], True)
          ]
      )
      arg_parser_arguments = {}
      for k, v in task_arguments.items():
          # python2 unicode support
          # noinspection PyBroadException
          try:
              v = str(v)
          except Exception:
              pass
  
          # if we have a StoreTrueAction and the value is either False or Empty or 0 change the default to False
          # with the rest we have to make sure the type is correct
          matched_actions = self._find_parser_action(parser, k)
          for parent_parser, current_action in matched_actions:
              if (
                  current_action
                  and current_action.default == SUPPRESS
                  and not v
              ):
                  # this value should be kept suppressed, do nothing
                  v = SUPPRESS
              elif current_action and isinstance(
                  current_action, _StoreConstAction
              ):
                  # make the default value boolean
                  # first check if False value
                  const_value = (
                      current_action.const
                      if current_action.const is not None
                      else (
                          current_action.default
                          if current_action.default is not None
                          else True
                      )
                  )
                  const_type = type(const_value)
                  strip_v = str(v).lower().strip()
                  if const_type == bool:
                      bool_value = cast_to_bool_int(strip_v)
                      if bool_value is not None:
                          const_value = bool_value
                  else:
                      const_value = strip_v
                  # then cast to const type (might be boolean)
                  try:
                      const_value = const_type(const_value)
                      current_action.const = const_value
                  except ValueError:
                      pass
                  if (
                      current_action.default is not None
                      or const_value not in (None, "")
                  ):
                      arg_parser_arguments[k] = const_value
              elif current_action and (
                  current_action.nargs in ("+", "*")
                  or isinstance(current_action.nargs, int)
                  or isinstance(current_action, _AppendAction)
              ):
                  # noinspection PyBroadException
                  try:
                      v = yaml.load(v.strip(), Loader=yaml.SafeLoader)
                      if not isinstance(v, (list, tuple)):
                          # we have no idea what happened, just put into a list.
                          v = [v] if v else None
                      # casting
                      if v:
                          if current_action.type:
                              v = [
                                  current_action.type(a)
                                  if str(a) != str(None)
                                  else None
                                  for a in v
                              ]
                          elif current_action.default:
                              v_type = type(current_action.default[0])
                              if v_type != type(None):  # noqa
                                  v = [
                                      v_type(a)
                                      if str(a) != str(None)
                                      else None
                                      for a in v
                                  ]
  
                      if (
                          current_action.default is not None
                          or v not in (None, "")
                      ):
                          arg_parser_arguments[k] = v
                  except Exception:
                      if self._task and self._task.log:
                          self._task.log.warning(
                              'Failed parsing task parameter {}="{}" keeping default {}={}'.format(
                                  k, v, k, current_action.default
                              )
                          )
                      continue
  
              elif current_action and not current_action.type:
                  # cast manually if there is no type
                  var_type = type(current_action.default)
                  # if we have an int, we should cast to float, because it is more generic
                  if var_type == int:
                      var_type = float
                  elif var_type == type(
                      None
                  ):  # noqa: E721 - do not change!
                      # because isinstance(var_type, type(None)) === False
                      var_type = str
                  elif var_type not in (
                      bool,
                      int,
                      float,
                      str,
                      dict,
                      list,
                      tuple,
                  ) and str(
                      self.__cast_arg(current_action.default)
                  ) == str(
                      v
                  ):
                      # there is nothing we can Do, just leave with the default
                      continue
  
                  # now we should try and cast the value if we can
                  # noinspection PyBroadException
                  try:
                      # Since we have no actual var type here, we check if the string presentation of the original
                      # default value and the new value are the same, if they are,
                      # we should just use the original default value
                      if str(v) == str(current_action.default):
                          v = current_action.default
                      else:
                          v = var_type(v)
                      # cast back to int if it's the same value
                      if (
                          type(current_action.default) == int
                          and int(v) == v
                      ):
                          arg_parser_arguments[k] = v = int(v)
                      elif current_action.default is None and v in (
                          None,
                          "",
                      ):
                          # Do nothing, we should leave it as is.
                          pass
                      else:
                          arg_parser_arguments[k] = v
                  except Exception:
                      # if we failed, leave as string
                      arg_parser_arguments[k] = v
              elif current_action and current_action.type == bool:
                  # parser.set_defaults cannot cast string `False`/`True` to boolean properly,
                  # so we have to do it manually here
                  strip_v = str(v).lower().strip()
                  if strip_v == "false" or not strip_v:
                      v = False
                  elif strip_v == "true":
                      v = True
                  else:
                      # else, try to cast to integer
                      try:
                          v = int(strip_v)
                      except ValueError:
                          pass
                  if v not in (None, ""):
                      arg_parser_arguments[k] = v
              elif current_action and current_action.type:
                  # if we have an action type and value (v) is None, and cannot be casted, leave as is
                  if isfunction(current_action.type) and not v:  # noqa
                      # noinspection PyBroadException
                      try:
                          v = current_action.type(v)
                      except Exception:
                          continue
                  elif (
                      current_action.type == str
                      and current_action.default is None
                      and v in (None, "")
                  ):
                      # if the type is str and the default is None, and we stored empty string,
                      # do not change the value (i.e. leave it as None)
                      continue
                  elif current_action.type == str and isinstance(
                      current_action.default, bool
                  ):
                      # this will take care of values that can be strings or boolean with default of boolean
                      # and the default value is kept the same
                      bool_value = cast_to_bool_int(v, strip=True)
                      if (
                          bool_value is not None
                          and current_action.default == bool(bool_value)
                      ):
                          continue
                  elif str(current_action.default) == v:
                      # if we changed nothing, leave it as is (i.e. default value)
                      v = current_action.default
  
                  arg_parser_arguments[k] = v
                  # noinspection PyBroadException
                  try:
                      if (
                          current_action.default is None
                          and current_action.type != str
                          and not v
                      ):
                          arg_parser_arguments[k] = v = None
                      elif (
                          not isfunction(current_action.type)
                          and current_action.default
                          == current_action.type(v)
                      ) or (
                          isfunction(current_action.type)
                          and str(
                              self.__cast_arg(current_action.default)
                          )
                          == str(v)
                      ):
                          # this will make sure that if we have type float and default value int,
                          # we will keep the type as int, just like the original argparser
                          arg_parser_arguments[
                              k
                          ] = v = current_action.default
                      else:
                          arg_parser_arguments[
                              k
                          ] = v = current_action.type(v)
                  except Exception:
                      pass
  
              # add as default
              # noinspection PyBroadException
              try:
                  if current_action and isinstance(
                      current_action, _SubParsersAction
                  ):
                      if v not in (
                          None,
                          "",
                      ) or current_action.default not in (None, ""):
                          current_action.default = v
                      current_action.required = False
                  elif current_action and isinstance(
                      current_action, _StoreAction
                  ):
                      if v not in (
                          None,
                          "",
                      ) or current_action.default not in (None, ""):
                          current_action.default = v
                      current_action.required = False
                      # python2 doesn't support defaults for positional arguments, unless used with nargs=?
                      if PY2 and not current_action.nargs:
                          current_action.nargs = "?"
                  else:
                      # do not add parameters that do not exist in argparser, they might be the dict
                      pass
              except ArgumentError:
                  pass
              except Exception:
                  pass
  
      self._remove_req_flag_from_mutex_groups(parser)
  
      # if API supports sections, we can update back the Args section with all the missing default
      if Session.check_min_api_version(
          "2.9"
      ) and not self._exclude_parser_args.get("*", None):
          # noinspection PyBroadException
          try:
              (
                  task_defaults,
                  task_defaults_descriptions,
                  task_defaults_types,
              ) = self._get_defaults_from_argparse(
                  parser, parsed_args=parsed_args
              )
              # select what's missing, and update it
              missing_keys = [
                  k
                  for k in task_defaults.keys()
                  if k[len(self._prefix_args) :] not in task_arguments
              ]
              task_defaults = {
                  k: v
                  for k, v in task_defaults.items()
                  if k in missing_keys
              }
              task_defaults_descriptions = {
                  k: v
                  for k, v in task_defaults_descriptions.items()
                  if k in missing_keys
              }
              task_defaults_types = {
                  k: v
                  for k, v in task_defaults_types.items()
                  if k in missing_keys
              }
              if task_defaults:
                  self._task.update_parameters(
                      task_defaults,
                      __parameters_descriptions=task_defaults_descriptions,
                      __parameters_types=task_defaults_types,
                  )
          except Exception:
              pass
  
      # if we already have an instance of parsed args, we should update its values
      # this instance should already contain our defaults
      if parsed_args:
          for k, v in arg_parser_arguments.items():
              cur_v = getattr(parsed_args, k, None)
              # it should not happen...
              if cur_v != v and (
                  cur_v is not None or v not in (None, "")
              ):
                  setattr(parsed_args, k, v)
      parser.set_defaults(**arg_parser_arguments)
  
imports: import yaml
  from enum import Enum
  from inspect import isfunction
  from six import PY2
  from argparse import _StoreAction, ArgumentError, _StoreConstAction, _SubParsersAction, _AppendAction, SUPPRESS
  from copy import copy
  from typing import Tuple, Type, Union
  from ...backend_api import Session
  from ...binding.args import call_original_argparser
  from ...utilities.proxy_object import get_type_from_basic_type_str
label_desc: Use image node_id 11 for calling the _Arguments obj's underlying member method code with example usage: obj.copy_to_parser(parser, parsed_args) and returns: False, True, int, None