class_docstr: Hook for Google Cloud Vertex AI Auto ML APIs.
class_docstr_tok: ["Hook","for","Google","Cloud","Vertex","AI","Auto","ML","APIs","."]
docstr: Create an AutoML Text Training Job.
  
  :param project_id: Required. Project to run training in.
  :param region: Required. Location to run training in.
  :param display_name: Required. The user-defined name of this TrainingPipeline.
  :param dataset: Required. The dataset within the same Project from which data will be used to train
      the Model. The Dataset must use schema compatible with Model being trained, and what is
      compatible should be described in the used TrainingPipeline's [training_task_definition]
      [google.cloud.aiplatform.v1beta1.TrainingPipeline.training_task_definition].
  :param prediction_type: The type of prediction the Model is to produce, one of:
      "classification" - A classification model analyzes text data and returns a list of categories
      that apply to the text found in the data. Vertex AI offers both single-label and multi-label text
      classification models.
      "extraction" - An entity extraction model inspects text data for known entities referenced in the
      data and labels those entities in the text.
      "sentiment" - A sentiment analysis model inspects text data and identifies the prevailing
      emotional opinion within it, especially to determine a writer's attitude as positive, negative,
      or neutral.
  :param parent_model: Optional. The resource name or model ID of an existing model.
      The new model uploaded by this job will be a version of `parent_model`.
      Only set this field when training a new version of an existing model.
  :param is_default_version: Optional. When set to True, the newly uploaded model version will
      automatically have alias "default" included. Subsequent uses of
      the model produced by this job without a version specified will
      use this "default" version.
      When set to False, the "default" alias will not be moved.
      Actions targeting the model version produced by this job will need
      to specifically reference this version by ID or alias.
      New model uploads, i.e. version 1, will always be "default" aliased.
  :param model_version_aliases: Optional. User provided version aliases so that the model version
      uploaded by this job can be referenced via alias instead of
      auto-generated version ID. A default version alias will be created
      for the first version of the model.
      The format is [a-z][a-zA-Z0-9-]{0,126}[a-z0-9]
  :param model_version_description: Optional. The description of the model version
      being uploaded by this job.
  :param multi_label: Required and only applicable for text classification task. If false, a
      single-label (multi-class) Model will be trained (i.e. assuming that for each text snippet just
      up to one annotation may be applicable). If true, a multi-label Model will be trained (i.e.
      assuming that for each text snippet multiple annotations may be applicable).
  :param sentiment_max: Required and only applicable for sentiment task. A sentiment is expressed as an
      integer ordinal, where higher value means a more positive sentiment. The range of sentiments that
      will be used is between 0 and sentimentMax (inclusive on both ends), and all the values in the
      range must be represented in the dataset before a model can be created. Only the Annotations with
      this sentimentMax will be used for training. sentimentMax value must be between 1 and 10
      (inclusive).
  :param labels: Optional. The labels with user-defined metadata to organize TrainingPipelines. Label
      keys and values can be no longer than 64 characters (Unicode codepoints), can only contain
      lowercase letters, numeric characters, underscores and dashes. International characters are
      allowed. See https://goo.gl/xmQnxf for more information and examples of labels.
  :param training_encryption_spec_key_name: Optional. The Cloud KMS resource identifier of the customer
      managed encryption key used to protect the training pipeline. Has the form:
      ``projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key``.
      The key needs to be in the same region as where the compute resource is created.
      If set, this TrainingPipeline will be secured by this key.
      Note: Model trained by this TrainingPipeline is also secured by this key if ``model_to_upload``
      is not set separately.
  :param model_encryption_spec_key_name: Optional. The Cloud KMS resource identifier of the customer
      managed encryption key used to protect the model. Has the form:
      ``projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key``.
      The key needs to be in the same region as where the compute resource is created.
      If set, the trained Model will be secured by this key.
  :param training_fraction_split: Optional. The fraction of the input data that is to be used to train
      the Model. This is ignored if Dataset is not provided.
  :param validation_fraction_split: Optional. The fraction of the input data that is to be used to
      validate the Model. This is ignored if Dataset is not provided.
  :param test_fraction_split: Optional. The fraction of the input data that is to be used to evaluate
      the Model. This is ignored if Dataset is not provided.
  :param training_filter_split: Optional. A filter on DataItems of the Dataset. DataItems that match
      this filter are used to train the Model. A filter with same syntax as the one used in
      DatasetService.ListDataItems may be used. If a single DataItem is matched by more than one of the
      FilterSplit filters, then it is assigned to the first set that applies to it in the training,
      validation, test order. This is ignored if Dataset is not provided.
  :param validation_filter_split: Optional. A filter on DataItems of the Dataset. DataItems that match
      this filter are used to validate the Model. A filter with same syntax as the one used in
      DatasetService.ListDataItems may be used. If a single DataItem is matched by more than one of the
      FilterSplit filters, then it is assigned to the first set that applies to it in the training,
      validation, test order. This is ignored if Dataset is not provided.
  :param test_filter_split: Optional. A filter on DataItems of the Dataset. DataItems that match this
      filter are used to test the Model. A filter with same syntax as the one used in
      DatasetService.ListDataItems may be used. If a single DataItem is matched by more than one of the
      FilterSplit filters, then it is assigned to the first set that applies to it in the training,
      validation, test order. This is ignored if Dataset is not provided.
  :param model_display_name: Optional. The display name of the managed Vertex AI Model. The name can be
      up to 128 characters long and can consist of any UTF-8 characters.
      If not provided upon creation, the job's display_name is used.
  :param model_labels: Optional. The labels with user-defined metadata to organize your Models. Label
      keys and values can be no longer than 64 characters (Unicode codepoints), can only contain
      lowercase letters, numeric characters, underscores and dashes. International characters are
      allowed. See https://goo.gl/xmQnxf for more information and examples of labels.
  :param sync: Whether to execute this method synchronously. If False, this method will be executed in
      concurrent Future and any downstream object will be immediately returned and synced when the
      Future has completed.
docstr_tok: ["Create","an","AutoML","Text","Training","Job",".",":","param","project_id",":","Required",".","Project","to","run","training","in",".",":","param","region",":","Required",".","Location","to","run","training","in",".",":","param","display_name",":","Required",".","The","user-defined","name","of","this","TrainingPipeline",".",":","param","dataset",":","Required",".","The","dataset","within","the","same","Project","from","which","data","will","be","used","to","train","the","Model",".","The","Dataset","must","use","schema","compatible","with","Model","being","trained",",","and","what","is","compatible","should","be","described","in","the","used","TrainingPipeline","'s","[","training_task_definition","]","[","google.cloud.aiplatform.v1beta1.TrainingPipeline.training_task_definition","]",".",":","param","prediction_type",":","The","type","of","prediction","the","Model","is","to","produce",",","one","of",":","``","classification","''","-","A","classification","model","analyzes","text","data","and","returns","a","list","of","categories","that","apply","to","the","text","found","in","the","data",".","Vertex","AI","offers","both","single-label","and","multi-label","text","classification","models",".","``","extraction","''","-","An","entity","extraction","model","inspects","text","data","for","known","entities","referenced","in","the","data","and","labels","those","entities","in","the","text",".","``","sentiment","''","-","A","sentiment","analysis","model","inspects","text","data","and","identifies","the","prevailing","emotional","opinion","within","it",",","especially","to","determine","a","writer","'s","attitude","as","positive",",","negative",",","or","neutral",".",":","param","parent_model",":","Optional",".","The","resource","name","or","model","ID","of","an","existing","model",".","The","new","model","uploaded","by","this","job","will","be","a","version","of","`","parent_model","`",".","Only","set","this","field","when","training","a","new","version","of","an","existing","model",".",":","param","is_default_version",":","Optional",".","When","set","to","True",",","the","newly","uploaded","model","version","will","automatically","have","alias","``","default","''","included",".","Subsequent","uses","of","the","model","produced","by","this","job","without","a","version","specified","will","use","this","``","default","''","version",".","When","set","to","False",",","the","``","default","''","alias","will","not","be","moved",".","Actions","targeting","the","model","version","produced","by","this","job","will","need","to","specifically","reference","this","version","by","ID","or","alias",".","New","model","uploads",",","i.e",".","version","1",",","will","always","be","``","default","''","aliased",".",":","param","model_version_aliases",":","Optional",".","User","provided","version","aliases","so","that","the","model","version","uploaded","by","this","job","can","be","referenced","via","alias","instead","of","auto-generated","version","ID",".","A","default","version","alias","will","be","created","for","the","first","version","of","the","model",".","The","format","is","[","a-z","]","[","a-zA-Z0-9-","]","{","0,126","}","[","a-z0-9","]",":","param","model_version_description",":","Optional",".","The","description","of","the","model","version","being","uploaded","by","this","job",".",":","param","multi_label",":","Required","and","only","applicable","for","text","classification","task",".","If","false",",","a","single-label","(","multi-class",")","Model","will","be","trained","(","i.e",".","assuming","that","for","each","text","snippet","just","up","to","one","annotation","may","be","applicable",")",".","If","true",",","a","multi-label","Model","will","be","trained","(","i.e",".","assuming","that","for","each","text","snippet","multiple","annotations","may","be","applicable",")",".",":","param","sentiment_max",":","Required","and","only","applicable","for","sentiment","task",".","A","sentiment","is","expressed","as","an","integer","ordinal",",","where","higher","value","means","a","more","positive","sentiment",".","The","range","of","sentiments","that","will","be","used","is","between","0","and","sentimentMax","(","inclusive","on","both","ends",")",",","and","all","the","values","in","the","range","must","be","represented","in","the","dataset","before","a","model","can","be","created",".","Only","the","Annotations","with","this","sentimentMax","will","be","used","for","training",".","sentimentMax","value","must","be","between","1","and","10","(","inclusive",")",".",":","param","labels",":","Optional",".","The","labels","with","user-defined","metadata","to","organize","TrainingPipelines",".","Label","keys","and","values","can","be","no","longer","than","64","characters","(","Unicode","codepoints",")",",","can","only","contain","lowercase","letters",",","numeric","characters",",","underscores","and","dashes",".","International","characters","are","allowed",".","See","https",":","\/\/goo.gl\/xmQnxf","for","more","information","and","examples","of","labels",".",":","param","training_encryption_spec_key_name",":","Optional",".","The","Cloud","KMS","resource","identifier","of","the","customer","managed","encryption","key","used","to","protect","the","training","pipeline",".","Has","the","form",":","``","projects\/my-project\/locations\/my-region\/keyRings\/my-kr\/cryptoKeys\/my-key","``",".","The","key","needs","to","be","in","the","same","region","as","where","the","compute","resource","is","created",".","If","set",",","this","TrainingPipeline","will","be","secured","by","this","key",".","Note",":","Model","trained","by","this","TrainingPipeline","is","also","secured","by","this","key","if","``","model_to_upload","``","is","not","set","separately",".",":","param","model_encryption_spec_key_name",":","Optional",".","The","Cloud","KMS","resource","identifier","of","the","customer","managed","encryption","key","used","to","protect","the","model",".","Has","the","form",":","``","projects\/my-project\/locations\/my-region\/keyRings\/my-kr\/cryptoKeys\/my-key","``",".","The","key","needs","to","be","in","the","same","region","as","where","the","compute","resource","is","created",".","If","set",",","the","trained","Model","will","be","secured","by","this","key",".",":","param","training_fraction_split",":","Optional",".","The","fraction","of","the","input","data","that","is","to","be","used","to","train","the","Model",".","This","is","ignored","if","Dataset","is","not","provided",".",":","param","validation_fraction_split",":","Optional",".","The","fraction","of","the","input","data","that","is","to","be","used","to","validate","the","Model",".","This","is","ignored","if","Dataset","is","not","provided",".",":","param","test_fraction_split",":","Optional",".","The","fraction","of","the","input","data","that","is","to","be","used","to","evaluate","the","Model",".","This","is","ignored","if","Dataset","is","not","provided",".",":","param","training_filter_split",":","Optional",".","A","filter","on","DataItems","of","the","Dataset",".","DataItems","that","match","this","filter","are","used","to","train","the","Model",".","A","filter","with","same","syntax","as","the","one","used","in","DatasetService.ListDataItems","may","be","used",".","If","a","single","DataItem","is","matched","by","more","than","one","of","the","FilterSplit","filters",",","then","it","is","assigned","to","the","first","set","that","applies","to","it","in","the","training",",","validation",",","test","order",".","This","is","ignored","if","Dataset","is","not","provided",".",":","param","validation_filter_split",":","Optional",".","A","filter","on","DataItems","of","the","Dataset",".","DataItems","that","match","this","filter","are","used","to","validate","the","Model",".","A","filter","with","same","syntax","as","the","one","used","in","DatasetService.ListDataItems","may","be","used",".","If","a","single","DataItem","is","matched","by","more","than","one","of","the","FilterSplit","filters",",","then","it","is","assigned","to","the","first","set","that","applies","to","it","in","the","training",",","validation",",","test","order",".","This","is","ignored","if","Dataset","is","not","provided",".",":","param","test_filter_split",":","Optional",".","A","filter","on","DataItems","of","the","Dataset",".","DataItems","that","match","this","filter","are","used","to","test","the","Model",".","A","filter","with","same","syntax","as","the","one","used","in","DatasetService.ListDataItems","may","be","used",".","If","a","single","DataItem","is","matched","by","more","than","one","of","the","FilterSplit","filters",",","then","it","is","assigned","to","the","first","set","that","applies","to","it","in","the","training",",","validation",",","test","order",".","This","is","ignored","if","Dataset","is","not","provided",".",":","param","model_display_name",":","Optional",".","The","display","name","of","the","managed","Vertex","AI","Model",".","The","name","can","be","up","to","128","characters","long","and","can","consist","of","any","UTF-8","characters",".","If","not","provided","upon","creation",",","the","job","'s","display_name","is","used",".",":","param","model_labels",":","Optional",".","The","labels","with","user-defined","metadata","to","organize","your","Models",".","Label","keys","and","values","can","be","no","longer","than","64","characters","(","Unicode","codepoints",")",",","can","only","contain","lowercase","letters",",","numeric","characters",",","underscores","and","dashes",".","International","characters","are","allowed",".","See","https",":","\/\/goo.gl\/xmQnxf","for","more","information","and","examples","of","labels",".",":","param","sync",":","Whether","to","execute","this","method","synchronously",".","If","False",",","this","method","will","be","executed","in","concurrent","Future","and","any","downstream","object","will","be","immediately","returned","and","synced","when","the","Future","has","completed","."]
code: def create_auto_ml_text_training_job(
      self,
      project_id: str,
      region: str,
      display_name: str,
      dataset: datasets.TextDataset,
      prediction_type: str,
      multi_label: bool = False,
      sentiment_max: int = 10,
      labels: dict[str, str] | None = None,
      training_encryption_spec_key_name: str | None = None,
      model_encryption_spec_key_name: str | None = None,
      training_fraction_split: float | None = None,
      validation_fraction_split: float | None = None,
      test_fraction_split: float | None = None,
      training_filter_split: str | None = None,
      validation_filter_split: str | None = None,
      test_filter_split: str | None = None,
      model_display_name: str | None = None,
      model_labels: dict[str, str] | None = None,
      sync: bool = True,
      parent_model: str | None = None,
      is_default_version: bool | None = None,
      model_version_aliases: list[str] | None = None,
      model_version_description: str | None = None,
  ) -> tuple[models.Model | None, str]:
      """
      Create an AutoML Text Training Job.
  
      :param project_id: Required. Project to run training in.
      :param region: Required. Location to run training in.
      :param display_name: Required. The user-defined name of this TrainingPipeline.
      :param dataset: Required. The dataset within the same Project from which data will be used to train
          the Model. The Dataset must use schema compatible with Model being trained, and what is
          compatible should be described in the used TrainingPipeline's [training_task_definition]
          [google.cloud.aiplatform.v1beta1.TrainingPipeline.training_task_definition].
      :param prediction_type: The type of prediction the Model is to produce, one of:
          "classification" - A classification model analyzes text data and returns a list of categories
          that apply to the text found in the data. Vertex AI offers both single-label and multi-label text
          classification models.
          "extraction" - An entity extraction model inspects text data for known entities referenced in the
          data and labels those entities in the text.
          "sentiment" - A sentiment analysis model inspects text data and identifies the prevailing
          emotional opinion within it, especially to determine a writer's attitude as positive, negative,
          or neutral.
      :param parent_model: Optional. The resource name or model ID of an existing model.
          The new model uploaded by this job will be a version of `parent_model`.
          Only set this field when training a new version of an existing model.
      :param is_default_version: Optional. When set to True, the newly uploaded model version will
          automatically have alias "default" included. Subsequent uses of
          the model produced by this job without a version specified will
          use this "default" version.
          When set to False, the "default" alias will not be moved.
          Actions targeting the model version produced by this job will need
          to specifically reference this version by ID or alias.
          New model uploads, i.e. version 1, will always be "default" aliased.
      :param model_version_aliases: Optional. User provided version aliases so that the model version
          uploaded by this job can be referenced via alias instead of
          auto-generated version ID. A default version alias will be created
          for the first version of the model.
          The format is [a-z][a-zA-Z0-9-]{0,126}[a-z0-9]
      :param model_version_description: Optional. The description of the model version
          being uploaded by this job.
      :param multi_label: Required and only applicable for text classification task. If false, a
          single-label (multi-class) Model will be trained (i.e. assuming that for each text snippet just
          up to one annotation may be applicable). If true, a multi-label Model will be trained (i.e.
          assuming that for each text snippet multiple annotations may be applicable).
      :param sentiment_max: Required and only applicable for sentiment task. A sentiment is expressed as an
          integer ordinal, where higher value means a more positive sentiment. The range of sentiments that
          will be used is between 0 and sentimentMax (inclusive on both ends), and all the values in the
          range must be represented in the dataset before a model can be created. Only the Annotations with
          this sentimentMax will be used for training. sentimentMax value must be between 1 and 10
          (inclusive).
      :param labels: Optional. The labels with user-defined metadata to organize TrainingPipelines. Label
          keys and values can be no longer than 64 characters (Unicode codepoints), can only contain
          lowercase letters, numeric characters, underscores and dashes. International characters are
          allowed. See https://goo.gl/xmQnxf for more information and examples of labels.
      :param training_encryption_spec_key_name: Optional. The Cloud KMS resource identifier of the customer
          managed encryption key used to protect the training pipeline. Has the form:
          ``projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key``.
          The key needs to be in the same region as where the compute resource is created.
          If set, this TrainingPipeline will be secured by this key.
          Note: Model trained by this TrainingPipeline is also secured by this key if ``model_to_upload``
          is not set separately.
      :param model_encryption_spec_key_name: Optional. The Cloud KMS resource identifier of the customer
          managed encryption key used to protect the model. Has the form:
          ``projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key``.
          The key needs to be in the same region as where the compute resource is created.
          If set, the trained Model will be secured by this key.
      :param training_fraction_split: Optional. The fraction of the input data that is to be used to train
          the Model. This is ignored if Dataset is not provided.
      :param validation_fraction_split: Optional. The fraction of the input data that is to be used to
          validate the Model. This is ignored if Dataset is not provided.
      :param test_fraction_split: Optional. The fraction of the input data that is to be used to evaluate
          the Model. This is ignored if Dataset is not provided.
      :param training_filter_split: Optional. A filter on DataItems of the Dataset. DataItems that match
          this filter are used to train the Model. A filter with same syntax as the one used in
          DatasetService.ListDataItems may be used. If a single DataItem is matched by more than one of the
          FilterSplit filters, then it is assigned to the first set that applies to it in the training,
          validation, test order. This is ignored if Dataset is not provided.
      :param validation_filter_split: Optional. A filter on DataItems of the Dataset. DataItems that match
          this filter are used to validate the Model. A filter with same syntax as the one used in
          DatasetService.ListDataItems may be used. If a single DataItem is matched by more than one of the
          FilterSplit filters, then it is assigned to the first set that applies to it in the training,
          validation, test order. This is ignored if Dataset is not provided.
      :param test_filter_split: Optional. A filter on DataItems of the Dataset. DataItems that match this
          filter are used to test the Model. A filter with same syntax as the one used in
          DatasetService.ListDataItems may be used. If a single DataItem is matched by more than one of the
          FilterSplit filters, then it is assigned to the first set that applies to it in the training,
          validation, test order. This is ignored if Dataset is not provided.
      :param model_display_name: Optional. The display name of the managed Vertex AI Model. The name can be
          up to 128 characters long and can consist of any UTF-8 characters.
          If not provided upon creation, the job's display_name is used.
      :param model_labels: Optional. The labels with user-defined metadata to organize your Models. Label
          keys and values can be no longer than 64 characters (Unicode codepoints), can only contain
          lowercase letters, numeric characters, underscores and dashes. International characters are
          allowed. See https://goo.gl/xmQnxf for more information and examples of labels.
      :param sync: Whether to execute this method synchronously. If False, this method will be executed in
          concurrent Future and any downstream object will be immediately returned and synced when the
          Future has completed.
      """
      self._job = self.get_auto_ml_text_training_job(
          project=project_id,
          location=region,
          display_name=display_name,
          prediction_type=prediction_type,
          multi_label=multi_label,
          sentiment_max=sentiment_max,
          labels=labels,
          training_encryption_spec_key_name=training_encryption_spec_key_name,
          model_encryption_spec_key_name=model_encryption_spec_key_name,
      )
  
      if not self._job:
          raise AirflowException(
              "AutoMLTextTrainingJob was not created"
          )
  
      model = self._job.run(
          dataset=dataset,
          training_fraction_split=training_fraction_split,
          validation_fraction_split=validation_fraction_split,
          test_fraction_split=test_fraction_split,
          training_filter_split=training_filter_split,
          validation_filter_split=validation_filter_split,
          test_filter_split=test_filter_split,
          model_display_name=model_display_name,
          model_labels=model_labels,
          sync=sync,
          parent_model=parent_model,
          is_default_version=is_default_version,
          model_version_aliases=model_version_aliases,
          model_version_description=model_version_description,
      )
      training_id = self.extract_training_id(self._job.resource_name)
      if model:
          model.wait()
      else:
          self.log.warning(
              "Training did not produce a Managed Model returning None. AutoML Text Training "
              "Pipeline is not configured to upload a Model."
          )
      return model, training_id
  
imports: from __future__ import annotations
  import warnings
  from typing import TYPE_CHECKING, Sequence
  from google.api_core.client_options import ClientOptions
  from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
  from google.cloud.aiplatform import AutoMLForecastingTrainingJob, AutoMLImageTrainingJob, AutoMLTabularTrainingJob, AutoMLTextTrainingJob, AutoMLVideoTrainingJob, datasets, models
  from google.cloud.aiplatform_v1 import JobServiceClient, PipelineServiceClient
  from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
  from airflow.providers.google.common.hooks.base_google import GoogleBaseHook
label_desc: Use image node_id 16 for calling the AutoMLHook obj's underlying member method code with example usage: obj.create_auto_ml_text_training_job(project_id, region, display_name, dataset, prediction_type, multi_label, sentiment_max, labels, training_encryption_spec_key_name, model_encryption_spec_key_name, training_fraction_split, validation_fraction_split, test_fraction_split, training_filter_split, validation_filter_split, test_filter_split, model_display_name, model_labels, sync, parent_model, is_default_version, model_version_aliases, model_version_description) and returns: model,  training_id