class_docstr: The SageMaker Debugger Rule class configures *debugging* rules to debug your training job.
  
  The debugging rules analyze tensor outputs from your training job
  and monitor conditions that are critical for the success of the training
  job.
  
  SageMaker Debugger comes pre-packaged with built-in *debugging* rules.
  For example, the debugging rules can detect whether gradients are getting too large or
  too small, or if a model is overfitting.
  For a full list of built-in rules for debugging, see
  `List of Debugger Built-in Rules
  <https://docs.aws.amazon.com/sagemaker/latest/dg/debugger-built-in-rules.html>`_.
  You can also write your own rules using the custom rule classmethod.
class_docstr_tok: ["The","SageMaker","Debugger","Rule","class","configures","*","debugging","*","rules","to","debug","your","training","job",".","The","debugging","rules","analyze","tensor","outputs","from","your","training","job","and","monitor","conditions","that","are","critical","for","the","success","of","the","training","job",".","SageMaker","Debugger","comes","pre-packaged","with","built-in","*","debugging","*","rules",".","For","example",",","the","debugging","rules","can","detect","whether","gradients","are","getting","too","large","or","too","small",",","or","if","a","model","is","overfitting",".","For","a","full","list","of","built-in","rules","for","debugging",",","see","`","List","of","Debugger","Built-in","Rules","<","https",":","\/\/docs.aws.amazon.com\/sagemaker\/latest\/dg\/debugger-built-in-rules.html",">","`","_",".","You","can","also","write","your","own","rules","using","the","custom","rule","classmethod","."]
docstr: Initialize a ``Rule`` object for a *custom* debugging rule.
  
  You can create a custom rule that analyzes tensors emitted
  during the training of a model
  and monitors conditions that are critical for the success of a training
  job. For more information, see `Create Debugger Custom Rules for Training Job
  Analysis
  <https://docs.aws.amazon.com/sagemaker/latest/dg/debugger-custom-rules.html>`_.
  
  Args:
      name (str): Required. The name of the debugger rule.
      image_uri (str or PipelineVariable): Required. The URI of the image to
          be used by the debugger rule.
      instance_type (str or PipelineVariable): Required. Type of EC2 instance to use,
          for example, 'ml.c4.xlarge'.
      volume_size_in_gb (int or PipelineVariable): Required. Size in GB of the
          EBS volume to use for storing data.
      source (str): Optional. A source file containing a rule to invoke. If provided,
          you must also provide rule_to_invoke. This can either be an S3 uri or
          a local path.
      rule_to_invoke (str or PipelineVariable): Optional. The name of the rule to
          invoke within the source. If provided, you must also provide source.
      container_local_output_path (str or PipelineVariable): Optional. The local path
          in the container.
      s3_output_path (str or PipelineVariable): Optional. The location in Amazon S3
          to store the output tensors.
          The default Debugger output path for debugging data is created under the
          default output path of the :class:`~sagemaker.estimator.Estimator` class.
          For example,
          s3://sagemaker-<region>-<12digit_account_id>/<training-job-name>/debug-output/.
      other_trials_s3_input_paths (list[str] or list[PipelineVariable]: Optional.
          The Amazon S3 input paths of other trials to use the SimilarAcrossRuns rule.
      rule_parameters (dict[str, str] or dict[str, PipelineVariable]): Optional.
          A dictionary of parameters for the rule.
      collections_to_save ([sagemaker.debugger.CollectionConfig]): Optional. A list
          of :class:`~sagemaker.debugger.CollectionConfig` objects to be saved.
  
  Returns:
      :class:`~sagemaker.debugger.Rule`: The instance of the custom rule.
code: def custom(
      cls,
      name: str,
      image_uri: Union[str, PipelineVariable],
      instance_type: Union[str, PipelineVariable],
      volume_size_in_gb: Union[int, PipelineVariable],
      source: Optional[str] = None,
      rule_to_invoke: Optional[Union[str, PipelineVariable]] = None,
      container_local_output_path: Optional[
          Union[str, PipelineVariable]
      ] = None,
      s3_output_path: Optional[Union[str, PipelineVariable]] = None,
      other_trials_s3_input_paths: Optional[
          List[Union[str, PipelineVariable]]
      ] = None,
      rule_parameters: Optional[
          Dict[str, Union[str, PipelineVariable]]
      ] = None,
      collections_to_save: Optional[List["CollectionConfig"]] = None,
      actions=None,
  ):
      """Initialize a ``Rule`` object for a *custom* debugging rule.
  
      You can create a custom rule that analyzes tensors emitted
      during the training of a model
      and monitors conditions that are critical for the success of a training
      job. For more information, see `Create Debugger Custom Rules for Training Job
      Analysis
      <https://docs.aws.amazon.com/sagemaker/latest/dg/debugger-custom-rules.html>`_.
  
      Args:
          name (str): Required. The name of the debugger rule.
          image_uri (str or PipelineVariable): Required. The URI of the image to
              be used by the debugger rule.
          instance_type (str or PipelineVariable): Required. Type of EC2 instance to use,
              for example, 'ml.c4.xlarge'.
          volume_size_in_gb (int or PipelineVariable): Required. Size in GB of the
              EBS volume to use for storing data.
          source (str): Optional. A source file containing a rule to invoke. If provided,
              you must also provide rule_to_invoke. This can either be an S3 uri or
              a local path.
          rule_to_invoke (str or PipelineVariable): Optional. The name of the rule to
              invoke within the source. If provided, you must also provide source.
          container_local_output_path (str or PipelineVariable): Optional. The local path
              in the container.
          s3_output_path (str or PipelineVariable): Optional. The location in Amazon S3
              to store the output tensors.
              The default Debugger output path for debugging data is created under the
              default output path of the :class:`~sagemaker.estimator.Estimator` class.
              For example,
              s3://sagemaker-<region>-<12digit_account_id>/<training-job-name>/debug-output/.
          other_trials_s3_input_paths (list[str] or list[PipelineVariable]: Optional.
              The Amazon S3 input paths of other trials to use the SimilarAcrossRuns rule.
          rule_parameters (dict[str, str] or dict[str, PipelineVariable]): Optional.
              A dictionary of parameters for the rule.
          collections_to_save ([sagemaker.debugger.CollectionConfig]): Optional. A list
              of :class:`~sagemaker.debugger.CollectionConfig` objects to be saved.
  
      Returns:
          :class:`~sagemaker.debugger.Rule`: The instance of the custom rule.
  
      """
      if (
          actions is not None
          and not rule_configs.is_valid_action_object(actions)
      ):
          raise RuntimeError(
              """`actions` must be of type `Action` or `ActionList`!"""
          )
  
      merged_rule_params = cls._set_rule_parameters(
          source,
          rule_to_invoke,
          other_trials_s3_input_paths,
          rule_parameters,
      )
  
      return cls(
          name=name,
          image_uri=image_uri,
          instance_type=instance_type,
          container_local_output_path=container_local_output_path,
          s3_output_path=s3_output_path,
          volume_size_in_gb=volume_size_in_gb,
          rule_parameters=merged_rule_params,
          collections_to_save=collections_to_save or [],
          actions=actions,
      )
  
imports: from __future__ import absolute_import
  from abc import ABC
  from typing import Union, Optional, List, Dict
  import attr
  import smdebug_rulesconfig
  from sagemaker import image_uris
  from sagemaker.utils import build_dict, name_from_base
  from sagemaker.workflow.entities import PipelineVariable
  from sagemaker.debugger.profiler_constants import DETAIL_PROF_PROCESSING_DEFAULT_INSTANCE_TYPE, DETAIL_PROF_PROCESSING_DEFAULT_VOLUME_SIZE
label_desc: Use image node_id 3 for calling the Rule obj's underlying member method code with example usage: obj.custom(cls, name, image_uri, instance_type, volume_size_in_gb, source, rule_to_invoke, container_local_output_path, s3_output_path, other_trials_s3_input_paths, rule_parameters, collections_to_save, actions) and returns: cls