code: 
  
  
  '''simple docstring'''
  
  
  
  
  
  import csv
  import os
  
  import pytest
  
  from datasets import Dataset, DatasetDict, Features, NamedSplit, Value
  from datasets.io.csv import CsvDatasetReader, CsvDatasetWriter
  
  from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases
  
  
  
  
  def       a__						(		snake_case__				:       Optional[int]	,      snake_case__				:       List[Any]    ):
    assert isinstance(snake_case__	,      snake_case__    )
    assert dataset.num_rows == 4
    assert dataset.num_columns == 3
    assert dataset.column_names == ["col_1", "col_2", "col_3"]
    for feature, expected_dtype in expected_features.items():
      assert dataset.features[feature].dtype == expected_dtype
  
  
  
  
  @pytest.mark.parametrize("""keep_in_memory"""	,      [False, True]    )
  def       a__						(		snake_case__				:       Dict	,      snake_case__				:       Union[str, Any]	,      snake_case__				:       Union[str, Any]    ):
    _UpperCAmelCase		:       Dict       =    tmp_path / """cache"""
    _UpperCAmelCase		:       List[Any]       =    {"""col_1""": """int64""", """col_2""": """int64""", """col_3""": """float64"""}
    with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
      _UpperCAmelCase		:       Tuple       =    CsvDatasetReader(snake_case__	,      cache_dir=snake_case__	,      keep_in_memory=snake_case__    ).read()
    _check_csv_dataset(snake_case__	,      snake_case__    )
  
  
  
  
  @pytest.mark.parametrize(
      """features"""	,      [
          None,
          {"""col_1""": """string""", """col_2""": """int64""", """col_3""": """float64"""},
          {"""col_1""": """string""", """col_2""": """string""", """col_3""": """string"""},
          {"""col_1""": """int32""", """col_2""": """int32""", """col_3""": """int32"""},
          {"""col_1""": """float32""", """col_2""": """float32""", """col_3""": """float32"""},
      ]	,      )
  def       a__						(		snake_case__				:       Optional[Any]	,      snake_case__				:       int	,      snake_case__				:       Optional[Any]    ):
    _UpperCAmelCase		:       Optional[Any]       =    tmp_path / """cache"""
    # CSV file loses col_1 string dtype information: default now is "int64" instead of "string"
    _UpperCAmelCase		:       Union[str, Any]       =    {"""col_1""": """int64""", """col_2""": """int64""", """col_3""": """float64"""}
    _UpperCAmelCase		:       Any       =    features.copy() if features else default_expected_features
    _UpperCAmelCase		:       Union[str, Any]       =    (
        Features({feature: Value(snake_case__    ) for feature, dtype in features.items()}    ) if features is not None else None
    )
    _UpperCAmelCase		:       Dict       =    CsvDatasetReader(snake_case__	,      features=snake_case__	,      cache_dir=snake_case__    ).read()
    _check_csv_dataset(snake_case__	,      snake_case__    )
  
  
  
  
  @pytest.mark.parametrize("""split"""	,      [None, NamedSplit("""train"""    ), """train""", """test"""]    )
  def       a__						(		snake_case__				:       Dict	,      snake_case__				:       int	,      snake_case__				:       Dict    ):
    _UpperCAmelCase		:       List[Any]       =    tmp_path / """cache"""
    _UpperCAmelCase		:       Optional[Any]       =    {"""col_1""": """int64""", """col_2""": """int64""", """col_3""": """float64"""}
    _UpperCAmelCase		:       List[str]       =    CsvDatasetReader(snake_case__	,      cache_dir=snake_case__	,      split=snake_case__    ).read()
    _check_csv_dataset(snake_case__	,      snake_case__    )
    assert dataset.split == split if split else "train"
  
  
  
  
  @pytest.mark.parametrize("""path_type"""	,      [str, list]    )
  def       a__						(		snake_case__				:       Optional[Any]	,      snake_case__				:       Tuple	,      snake_case__				:       Dict    ):
    if issubclass(snake_case__	,      snake_case__    ):
      _UpperCAmelCase		:       str       =    csv_path
    elif issubclass(snake_case__	,      snake_case__    ):
      _UpperCAmelCase		:       List[Any]       =    [csv_path]
    _UpperCAmelCase		:       str       =    tmp_path / """cache"""
    _UpperCAmelCase		:       Dict       =    {"""col_1""": """int64""", """col_2""": """int64""", """col_3""": """float64"""}
    _UpperCAmelCase		:       Optional[Any]       =    CsvDatasetReader(snake_case__	,      cache_dir=snake_case__    ).read()
    _check_csv_dataset(snake_case__	,      snake_case__    )
  
  
  
  
  def       a__						(		snake_case__				:       Tuple	,      snake_case__				:       Optional[Any]	,      snake_case__				:       int=("train",)    ):
    assert isinstance(snake_case__	,      snake_case__    )
    for split in splits:
      _UpperCAmelCase		:       Dict       =    dataset_dict[split]
      assert dataset.num_rows == 4
      assert dataset.num_columns == 3
      assert dataset.column_names == ["col_1", "col_2", "col_3"]
      for feature, expected_dtype in expected_features.items():
        assert dataset.features[feature].dtype == expected_dtype
  
  
  
  
  @pytest.mark.parametrize("""keep_in_memory"""	,      [False, True]    )
  def       a__						(		snake_case__				:       Optional[Any]	,      snake_case__				:       Any	,      snake_case__				:       Tuple    ):
    _UpperCAmelCase		:       Dict       =    tmp_path / """cache"""
    _UpperCAmelCase		:       int       =    {"""col_1""": """int64""", """col_2""": """int64""", """col_3""": """float64"""}
    with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
      _UpperCAmelCase		:       Any       =    CsvDatasetReader({"""train""": csv_path}	,      cache_dir=snake_case__	,      keep_in_memory=snake_case__    ).read()
    _check_csv_datasetdict(snake_case__	,      snake_case__    )
  
  
  
  
  @pytest.mark.parametrize(
      """features"""	,      [
          None,
          {"""col_1""": """string""", """col_2""": """int64""", """col_3""": """float64"""},
          {"""col_1""": """string""", """col_2""": """string""", """col_3""": """string"""},
          {"""col_1""": """int32""", """col_2""": """int32""", """col_3""": """int32"""},
          {"""col_1""": """float32""", """col_2""": """float32""", """col_3""": """float32"""},
      ]	,      )
  def       a__						(		snake_case__				:       Optional[int]	,      snake_case__				:       List[Any]	,      snake_case__				:       List[Any]    ):
    _UpperCAmelCase		:       Tuple       =    tmp_path / """cache"""
    # CSV file loses col_1 string dtype information: default now is "int64" instead of "string"
    _UpperCAmelCase		:       Any       =    {"""col_1""": """int64""", """col_2""": """int64""", """col_3""": """float64"""}
    _UpperCAmelCase		:       Dict       =    features.copy() if features else default_expected_features
    _UpperCAmelCase		:       Optional[int]       =    (
        Features({feature: Value(snake_case__    ) for feature, dtype in features.items()}    ) if features is not None else None
    )
    _UpperCAmelCase		:       Optional[Any]       =    CsvDatasetReader({"""train""": csv_path}	,      features=snake_case__	,      cache_dir=snake_case__    ).read()
    _check_csv_datasetdict(snake_case__	,      snake_case__    )
  
  
  
  
  @pytest.mark.parametrize("""split"""	,      [None, NamedSplit("""train"""    ), """train""", """test"""]    )
  def       a__						(		snake_case__				:       Union[str, Any]	,      snake_case__				:       Any	,      snake_case__				:       List[Any]    ):
    if split:
      _UpperCAmelCase		:       Dict       =    {split: csv_path}
    else:
      _UpperCAmelCase		:       Any       =    {"""train""": csv_path, """test""": csv_path}
    _UpperCAmelCase		:       List[str]       =    tmp_path / """cache"""
    _UpperCAmelCase		:       Optional[int]       =    {"""col_1""": """int64""", """col_2""": """int64""", """col_3""": """float64"""}
    _UpperCAmelCase		:       Union[str, Any]       =    CsvDatasetReader(snake_case__	,      cache_dir=snake_case__    ).read()
    _check_csv_datasetdict(snake_case__	,      snake_case__	,      splits=list(path.keys()    )    )
    assert all(dataset[split].split == split for split in path.keys()    )
  
  
  
  
  def       a__						(		snake_case__				:       int    ):
    with open(snake_case__	,      encoding="""utf-8"""    ) as csvfile:
      yield from csv.reader(snake_case__    )
  
  
  
  
  def       a__						(		snake_case__				:       Any	,      snake_case__				:       Optional[int]    ):
    _UpperCAmelCase		:       str       =    tmp_path / """cache"""
    _UpperCAmelCase		:       Union[str, Any]       =    os.path.join(snake_case__	,      """tmp.csv"""    )
    _UpperCAmelCase		:       Optional[Any]       =    CsvDatasetReader({"""train""": csv_path}	,      cache_dir=snake_case__    ).read()
    CsvDatasetWriter(dataset["""train"""]	,      snake_case__	,      num_proc=1    ).write()
  
    _UpperCAmelCase		:       Union[str, Any]       =    iter_csv_file(snake_case__    )
    _UpperCAmelCase		:       Union[str, Any]       =    iter_csv_file(snake_case__    )
  
    for rowa, rowa in zip(snake_case__	,      snake_case__    ):
      assert rowa == rowa
  
  
  
  
  def       a__						(		snake_case__				:       List[str]	,      snake_case__				:       Optional[Any]    ):
    _UpperCAmelCase		:       Any       =    tmp_path / """cache"""
    _UpperCAmelCase		:       Any       =    os.path.join(snake_case__	,      """tmp.csv"""    )
    _UpperCAmelCase		:       str       =    CsvDatasetReader({"""train""": csv_path}	,      cache_dir=snake_case__    ).read()
    CsvDatasetWriter(dataset["""train"""]	,      snake_case__	,      num_proc=2    ).write()
  
    _UpperCAmelCase		:       List[str]       =    iter_csv_file(snake_case__    )
    _UpperCAmelCase		:       Dict       =    iter_csv_file(snake_case__    )
  
    for rowa, rowa in zip(snake_case__	,      snake_case__    ):
      assert rowa == rowa
  
  
  
  
  
  def       a__						(		snake_case__				:       Tuple	,      snake_case__				:       Dict    ):
    _UpperCAmelCase		:       Tuple       =    tmp_path / """cache"""
    _UpperCAmelCase		:       Tuple       =    os.path.join(snake_case__	,      """tmp.csv"""    )
    _UpperCAmelCase		:       List[Any]       =    CsvDatasetReader({"""train""": csv_path}	,      cache_dir=snake_case__    ).read()
    with pytest.raises(snake_case__    ):
      CsvDatasetWriter(dataset["""train"""]	,      snake_case__	,      num_proc=0    )
  
  
  
  
  
  
style_context: 
  
  
  from dataclasses import dataclass
  from enum import Enum
  from typing import List, Optional, Union
  
  import numpy as np
  import PIL
  from PIL import Image
  
  from ...utils import BaseOutput, is_torch_available, is_transformers_available
  
  
  @dataclass
  class 		_SCREAMING_SNAKE_CASE    (	A    ):
       __SCREAMING_SNAKE_CASE    				=						{
           '''sld_warmup_steps''': 1_5,
           '''sld_guidance_scale''': 2_0,
           '''sld_threshold''': 0.0,
           '''sld_momentum_scale''': 0.0,
           '''sld_mom_beta''': 0.0,
       }
       __SCREAMING_SNAKE_CASE    				=						{
           '''sld_warmup_steps''': 1_0,
           '''sld_guidance_scale''': 1_0_0_0,
           '''sld_threshold''': 0.01,
           '''sld_momentum_scale''': 0.3,
           '''sld_mom_beta''': 0.4,
       }
       __SCREAMING_SNAKE_CASE    				=						{
           '''sld_warmup_steps''': 7,
           '''sld_guidance_scale''': 2_0_0_0,
           '''sld_threshold''': 0.025,
           '''sld_momentum_scale''': 0.5,
           '''sld_mom_beta''': 0.7,
       }
       __SCREAMING_SNAKE_CASE    				=						{
           '''sld_warmup_steps''': 0,
           '''sld_guidance_scale''': 5_0_0_0,
           '''sld_threshold''': 1.0,
           '''sld_momentum_scale''': 0.5,
           '''sld_mom_beta''': 0.7,
       }
  
  
  @dataclass
  class 		_SCREAMING_SNAKE_CASE    (	A    ):
       __SCREAMING_SNAKE_CASE    				=						42
       __SCREAMING_SNAKE_CASE    				=						42
       __SCREAMING_SNAKE_CASE    				=						42
       __SCREAMING_SNAKE_CASE    				=						42
  
  
  if is_transformers_available() and is_torch_available():
   from .pipeline_stable_diffusion_safe import StableDiffusionPipelineSafe
   from .safety_checker import SafeStableDiffusionSafetyChecker
  
  
  
  
  
  