class_docstr: The configuration for framework metrics to be collected for Python profiling.
docstr: Choose a Python profiler: cProfile or Pyinstrument.
  
  Specify target steps or a target duration to profile.
  If no parameter is specified,
  it profiles based on profiling configurations
  preset by the **profile_default_steps** parameter,
  which is set to `True` by default.
  If you specify the following parameters,
  then the **profile_default_steps** parameter
  will be ignored.
  
  Args:
      start_step (int): The step to start profiling. The default is step 9.
      num_steps (int): The number of steps to profile. The default is for 3 steps.
      start_unix_time (int): The Unix time to start profiling.
      duration (float): The duration in seconds to profile.
      profile_default_steps (bool): Indicates whether the default configuration
          should be used. If set to `True`, Python profiling will be done
          at step 9, 10, and 11 of training, using cProfiler
          and collecting metrics based on the total time, cpu time,
          and off cpu time for these three steps respectively.
          The default is ``True``.
      python_profiler (PythonProfiler): The Python profiler to use to collect
          python profiling stats. Available options are ``"cProfile"``
          and ``"Pyinstrument"``. The default is ``"cProfile"``.
          Instead of passing the string values, you can also use the enumerator util,
          :class:`~sagemaker.debugger.utils.PythonProfiler`,
          to choose one of the available options.
      cprofile_timer (cProfileTimer): The timer to be used by cProfile when collecting
          python profiling stats. Available options are ``"total_time"``, ``"cpu_time"``,
          and ``"off_cpu_time"``. The default is ``"total_time"``.
          If you choose Pyinstrument, this parameter is ignored.
          Instead of passing the string values, you can also use the enumerator util,
          :class:`~sagemaker.debugger.utils.cProfileTimer`,
          to choose one of the available options.
docstr_tok: ["Choose","a","Python","profiler",":","cProfile","or","Pyinstrument",".","Specify","target","steps","or","a","target","duration","to","profile",".","If","no","parameter","is","specified",",","it","profiles","based","on","profiling","configurations","preset","by","the","*","*","profile_default_steps","*","*","parameter",",","which","is","set","to","`","True","`","by","default",".","If","you","specify","the","following","parameters",",","then","the","*","*","profile_default_steps","*","*","parameter","will","be","ignored",".","Args",":","start_step","(","int",")",":","The","step","to","start","profiling",".","The","default","is","step","9.","num_steps","(","int",")",":","The","number","of","steps","to","profile",".","The","default","is","for","3","steps",".","start_unix_time","(","int",")",":","The","Unix","time","to","start","profiling",".","duration","(","float",")",":","The","duration","in","seconds","to","profile",".","profile_default_steps","(","bool",")",":","Indicates","whether","the","default","configuration","should","be","used",".","If","set","to","`","True","`",",","Python","profiling","will","be","done","at","step","9",",","10",",","and","11","of","training",",","using","cProfiler","and","collecting","metrics","based","on","the","total","time",",","cpu","time",",","and","off","cpu","time","for","these","three","steps","respectively",".","The","default","is","``","True","``",".","python_profiler","(","PythonProfiler",")",":","The","Python","profiler","to","use","to","collect","python","profiling","stats",".","Available","options","are","``","``","cProfile","''","``","and","``","``","Pyinstrument","''","``",".","The","default","is","``","``","cProfile","''","``",".","Instead","of","passing","the","string","values",",","you","can","also","use","the","enumerator","util",",",":","class",":","`","~sagemaker.debugger.utils.PythonProfiler","`",",","to","choose","one","of","the","available","options",".","cprofile_timer","(","cProfileTimer",")",":","The","timer","to","be","used","by","cProfile","when","collecting","python","profiling","stats",".","Available","options","are","``","``","total_time","''","``",",","``","``","cpu_time","''","``",",","and","``","``","off_cpu_time","''","``",".","The","default","is","``","``","total_time","''","``",".","If","you","choose","Pyinstrument",",","this","parameter","is","ignored",".","Instead","of","passing","the","string","values",",","you","can","also","use","the","enumerator","util",",",":","class",":","`","~sagemaker.debugger.utils.cProfileTimer","`",",","to","choose","one","of","the","available","options","."]
code: def __init__(
      self,
      start_step=None,
      num_steps=None,
      start_unix_time=None,
      duration=None,
      profile_default_steps=False,
      python_profiler=PythonProfiler.CPROFILE,
      cprofile_timer=cProfileTimer.TOTAL_TIME,
  ):
      """Choose a Python profiler: cProfile or Pyinstrument.
  
      Specify target steps or a target duration to profile.
      If no parameter is specified,
      it profiles based on profiling configurations
      preset by the **profile_default_steps** parameter,
      which is set to `True` by default.
      If you specify the following parameters,
      then the **profile_default_steps** parameter
      will be ignored.
  
      Args:
          start_step (int): The step to start profiling. The default is step 9.
          num_steps (int): The number of steps to profile. The default is for 3 steps.
          start_unix_time (int): The Unix time to start profiling.
          duration (float): The duration in seconds to profile.
          profile_default_steps (bool): Indicates whether the default configuration
              should be used. If set to `True`, Python profiling will be done
              at step 9, 10, and 11 of training, using cProfiler
              and collecting metrics based on the total time, cpu time,
              and off cpu time for these three steps respectively.
              The default is ``True``.
          python_profiler (PythonProfiler): The Python profiler to use to collect
              python profiling stats. Available options are ``"cProfile"``
              and ``"Pyinstrument"``. The default is ``"cProfile"``.
              Instead of passing the string values, you can also use the enumerator util,
              :class:`~sagemaker.debugger.utils.PythonProfiler`,
              to choose one of the available options.
          cprofile_timer (cProfileTimer): The timer to be used by cProfile when collecting
              python profiling stats. Available options are ``"total_time"``, ``"cpu_time"``,
              and ``"off_cpu_time"``. The default is ``"total_time"``.
              If you choose Pyinstrument, this parameter is ignored.
              Instead of passing the string values, you can also use the enumerator util,
              :class:`~sagemaker.debugger.utils.cProfileTimer`,
              to choose one of the available options.
  
      """
      assert isinstance(
          profile_default_steps, bool
      ), ErrorMessages.INVALID_PROFILE_DEFAULT_STEPS.value
      if (
          profile_default_steps
          or start_step
          is num_steps
          is start_unix_time
          is duration
          is None
      ):
          start_step = PYTHON_PROFILING_START_STEP_DEFAULT
          num_steps = PYTHON_PROFILING_NUM_STEPS_DEFAULT
  
      if profile_default_steps:
          cprofile_timer = cProfileTimer.DEFAULT
  
      super().__init__(
          PYTHON_PROFILING_CONFIG_NAME,
          start_step,
          num_steps,
          start_unix_time,
          duration,
      )
  
      assert isinstance(
          python_profiler, PythonProfiler
      ), ErrorMessages.INVALID_PYTHON_PROFILER.value
      assert isinstance(
          cprofile_timer, cProfileTimer
      ), ErrorMessages.INVALID_CPROFILE_TIMER.value
  
      self.python_profiler = python_profiler
  
      # The cprofile timer can only be used when the python profiler is cProfile.
      if python_profiler == PythonProfiler.PYINSTRUMENT:
          self.cprofile_timer = None
      else:
          self.cprofile_timer = cprofile_timer
  
imports: from __future__ import absolute_import
  from sagemaker.debugger.profiler_constants import DATALOADER_PROFILING_CONFIG_NAME, DATALOADER_PROFILING_START_STEP_DEFAULT, DETAILED_PROFILING_CONFIG_NAME, DETAILED_PROFILING_START_STEP_DEFAULT, SMDATAPARALLEL_PROFILING_CONFIG_NAME, SMDATAPARALLEL_PROFILING_START_STEP_DEFAULT, HOROVOD_PROFILING_CONFIG_NAME, HOROVOD_PROFILING_START_STEP_DEFAULT, PROFILING_NUM_STEPS_DEFAULT, PYTHON_PROFILING_CONFIG_NAME, PYTHON_PROFILING_NUM_STEPS_DEFAULT, PYTHON_PROFILING_START_STEP_DEFAULT, START_STEP_DEFAULT
  from sagemaker.debugger.utils import convert_json_config_to_string, cProfileTimer, is_valid_regex, is_valid_unix_time, ErrorMessages, PythonProfiler
label_desc: Use image node_id 1 to create a new PythonProfilingConfig object from inherited base classes: MetricsConfigBase with example: obj = PythonProfilingConfig(start_step, num_steps, start_unix_time, duration, profile_default_steps, python_profiler, cprofile_timer)