o
    e                     @  sz  d Z ddlmZ ddlZddlZddlZddlZddlZddlm	Z	m
Z
mZmZ ddlmZmZ ddlmZmZmZmZ ddlmZ ddlmZmZmZmZmZmZmZmZ dd	l m!Z! dd
l"m#Z# ddl$m%Z%m&Z&m'Z' ddl(m)Z)m*Z*m+Z+ ddl,m-Z-m.Z.m/Z/m0Z0 ddl1m2Z2 ddl3m4Z5 ed e	rddl6m7Z7 edddddG dd deZ8e G dd deZ9d"d#d d!Z:dS )$zk
This file defines two useful high-level abstractions to build Gradio apps: Interface and TabbedInterface.
    )annotationsN)TYPE_CHECKINGAnyCallableLiteral)documentset_documentation_group)Examplesexternalinterpretationutils)Blocks)ButtonClearButtonDuplicateButtonInterpretationIOComponentMarkdownStateget_component_instance)InterfaceTypeswarn_deprecation)
Changeable
StreamableSubmittable)	CSVLoggerFlaggingCallback
FlagMethod)ColumnRowTabTabs)load_from_pipeline)
ThemeClass	interface)PipelineZlaunchloadfrom_pipelineZ	integratequeuec                      s&  e Zd ZU dZe Zded< eduddZ	e			dvdwddZ
edxddZddddddddddddddde ddddddfdy fdAdBZdzdDdEZd{dGdHZd|dJdKZd}dOdPZdQdR Zd~ fdUdVZdd\d]ZddadbZddedfZdgdh Zdidj Zdkdl Zdmdn ZddqdrZdzdsdtZ  ZS )	Interfaceak  
    Interface is Gradio's main high-level class, and allows you to create a web-based GUI / demo
    around a machine learning model (or any Python function) in a few lines of code.
    You must specify three parameters: (1) the function to create a GUI for (2) the desired input components and
    (3) the desired output components. Additional parameters can be used to control the appearance
    and behavior of the demo.

    Example:
        import gradio as gr

        def image_classifier(inp):
            return {'cat': 0.3, 'dog': 0.7}

        demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label")
        demo.launch()
    Demos: hello_world, hello_world_3, gpt2_xl
    Guides: quickstart, key-features, sharing-your-app, interface-state, reactive-interfaces, advanced-interface-features, setting-up-a-gradio-demo-for-maximum-performance
    zweakref.WeakSet	instancesreturnlist[Interface]c                 C  s
   t tjS )z9
        :return: list of all current instances.
        )listr*   r+   )cls r0   @D:\Projects\ConvertPro\env\Lib\site-packages\gradio/interface.pyget_instancesB   s   
zInterface.get_instancesNnamestrsrc
str | Noneapi_keyaliasr   c                 K  s"   t d tjd||||d|S )a  
        Warning: this method will be deprecated. Use the equivalent `gradio.load()` instead. This is a class
        method that constructs a Blocks from a Hugging Face repo. Can accept
        model repos (if src is "models") or Space repos (if src is "spaces"). The input
        and output components are automatically loaded from the repo.
        Parameters:
            name: the name of the model (e.g. "gpt2" or "facebook/bart-base") or space (e.g. "flax-community/spanish-gpt2"), can include the `src` as prefix (e.g. "models/facebook/bart-base")
            src: the source of the model: `models` or `spaces` (or leave empty if source is provided as a prefix in `name`)
            api_key: optional access token for loading private Hugging Face Hub models or spaces. Find your token here: https://huggingface.co/settings/tokens. Warning: only provide this if you are loading a trusted private Space as it can be read by the Space you are loading.
            alias: optional string used as the name of the loaded model instead of the default name (only applies if loading a Space running Gradio 2.x)
        Returns:
            a Gradio Interface object for the given model
        z>gr.Interface.load() will be deprecated. Use gr.load() instead.)r3   r5   Zhf_tokenr8   Nr0   )r   r
   r'   )r/   r3   r5   r7   r8   kwargsr0   r0   r1   r'   I   s   zInterface.loadpipeliner&   c                 K  s*   t |}t|fi |}| di |}|S )a#  
        Class method that constructs an Interface from a Hugging Face transformers.Pipeline object.
        The input and output components are automatically determined from the pipeline.
        Parameters:
            pipeline: the pipeline object to use.
        Returns:
            a Gradio Interface object from the given Pipeline
        Example:
            import gradio as gr
            from transformers import pipeline
            pipe = pipeline("image-classification")
            gr.Interface.from_pipeline(pipe).launch()
        Nr0   )r#   dict)r/   r:   r9   Zinterface_infor%   r0   r0   r1   r(   f   s   zInterface.from_pipeline
   Fg       @Zflagged   Zpredictfnr   inputs2str | IOComponent | list[str | IOComponent] | Noneoutputsexamples(list[Any] | list[list[Any]] | str | Nonecache_examplesbool | Noneexamples_per_pageintliveboolr   Callable | str | Nonenum_shapfloattitledescriptionarticle	thumbnailthemeTheme | str | Nonecssallow_flaggingflagging_options(list[str] | list[tuple[str, str]] | Noneflagging_dirflagging_callbackr   analytics_enabledbatchmax_batch_sizeapi_namestr | Literal[False] | None	_api_modeallow_duplicationc           5   	     sz  t  jd-|d||
p
d|d| || _t|trtdtj| _|du s)|g kr5|du s1|g kr5t	d|du s=|g krDg }tj
| _n|du sL|g krRg }tj| _t|tttfs\J t|tttfsfJ t|tsn|g}t|tsv|g}| jr|du rd| _n|pd| _d	d
 t|D }dd
 t|D }t|dkrt|dkrnAt|dkst|dkrt	d|d }|d }|| dkrt|| }t|d} n|| } | ||< | ||< |rtd d| _dd
 |D | _dd
 |D | _| j| j D ]}!t|!tst	|! dqt| jt| jkr,dd
 t| j| jD }"t|"r,tj| _| jtjtjfv rN| jD ]}#t|#tsCJ |#jdu rLd|#_q9 du s^t ts^t rb | _nt trt fdd
| jD | _nt	d|| _|| _ ddg| _!t"|dd| _#|| _$|
| _%t&|| _'|| _(|durt)|}|| _*|| _+|| _,|	| _-|| _.d| _/|du rt01dd}|du rtd d| _2n-|dkrd| _2n$|du rtd d| _2n|dkrd| _2n|dkrd| _2nt	d |du rd!g| _3n/t|tst	d"td#d$ |D r"d%d
 |D | _3ntd&d$ |D r0|| _3nt	d"|| _4|| _5|| _6|| _7|| _8d| _9d| _:d| _;d| _<t=j>?|  t@| j }$tAB| j d }%t|%dkrwtAC| j rw|%dd }%|%D D ]}&tE|&|$r|%F|& q{t| j|%D ]\}!}&t|!tsJ |!jGdu r|&|!_Gqt| jD ]&\}'}!t|!tsJ |!jGdu rt| jdkrd'|!_Gqd(|' |!_Gq| j2dkr| jtjks| j2dkr| j4H| j| j5 n| jtj
krn| j4H| j| j | j5 |  | I  d)\}(})}*}+},d*\}-}.d*\}/}0tJdd+H | jtjtj
tjfv r8| K \}(})}*}+}/}0}.| jtjtjfv ra| L|(\}1}2},}3}4}-|(pQ|1}(|)pV|2})|*p[|3}*|+p`|4}+W d   n	1 slw   Y  |)duszJ d,| M|(|* | N|)|/|0 |,dur|,O  | P|-|.|/|0 | Q|+|) | R  | S  W d   n	1 sw   Y  | T | _UdS ).aH  
        Parameters:
            fn: the function to wrap an interface around. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
            inputs: a single Gradio component, or list of Gradio components. Components can either be passed as instantiated objects, or referred to by their string shortcuts. The number of input components should match the number of parameters in fn. If set to None, then only the output components will be displayed.
            outputs: a single Gradio component, or list of Gradio components. Components can either be passed as instantiated objects, or referred to by their string shortcuts. The number of output components should match the number of values returned by fn. If set to None, then only the input components will be displayed.
            examples: sample inputs for the function; if provided, appear below the UI components and can be clicked to populate the interface. Should be nested list, in which the outer list consists of samples and each inner list consists of an input corresponding to each input component. A string path to a directory of examples can also be provided, but it should be within the directory with the python file running the gradio app. If there are multiple input components and a directory is provided, a log.csv file must be present in the directory to link corresponding inputs.
            cache_examples: If True, caches examples in the server for fast runtime in examples. If `fn` is a generator function, then the last yielded value will be used as the output. The default option in HuggingFace Spaces is True. The default option elsewhere is False.
            examples_per_page: If examples are provided, how many to display per page.
            live: whether the interface should automatically rerun if any of the inputs change.
            interpretation: function that provides interpretation explaining prediction output. Pass "default" to use simple built-in interpreter, "shap" to use a built-in shapley-based interpreter, or your own custom interpretation function. For more information on the different interpretation methods, see the Advanced Interface Features guide.
            num_shap: a multiplier that determines how many examples are computed for shap-based interpretation. Increasing this value will increase shap runtime, but improve results. Only applies if interpretation is "shap".
            title: a title for the interface; if provided, appears above the input and output components in large font. Also used as the tab title when opened in a browser window.
            description: a description for the interface; if provided, appears above the input and output components and beneath the title in regular font. Accepts Markdown and HTML content.
            article: an expanded article explaining the interface; if provided, appears below the input and output components in regular font. Accepts Markdown and HTML content.
            thumbnail: path or url to image to use as display image when the web demo is shared on social media.
            theme: Theme to use, loaded from gradio.themes.
            css: custom css or path to custom css file to use with interface.
            allow_flagging: one of "never", "auto", or "manual". If "never" or "auto", users will not see a button to flag an input and output. If "manual", users will see a button to flag. If "auto", every input the user submits will be automatically flagged (outputs are not flagged). If "manual", both the input and outputs are flagged when the user clicks flag button. This parameter can be set with environmental variable GRADIO_ALLOW_FLAGGING; otherwise defaults to "manual".
            flagging_options: if provided, allows user to select from the list of options when flagging. Only applies if allow_flagging is "manual". Can either be a list of tuples of the form (label, value), where label is the string that will be displayed on the button and value is the string that will be stored in the flagging CSV; or it can be a list of strings ["X", "Y"], in which case the values will be the list of strings and the labels will ["Flag as X", "Flag as Y"], etc.
            flagging_dir: what to name the directory where flagged data is stored.
            flagging_callback: An instance of a subclass of FlaggingCallback which will be called when a sample is flagged. By default logs to a local CSV file.
            analytics_enabled: Whether to allow basic telemetry. If None, will use GRADIO_ANALYTICS_ENABLED environment variable if defined, or default to True.
            batch: If True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
            max_batch_size: Maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
            api_name: Defines how the endpoint appears in the API docs. Can be a string, None, or False. If False or None, the endpoint will not be exposed in the api docs. If set to a string, the endpoint will be exposed in the api docs with the given name. Default value is "predict".
            allow_duplication: If True, then will show a 'Duplicate Spaces' button on Hugging Face Spaces.
        r%   Gradio)rY   moderS   rM   rQ   zThe `fn` parameter only accepts a single function, support for a list of functions has been deprecated. Please use gradio.mix.Parallel instead.Nz2Must provide at least one of `inputs` or `outputs`TFc                 S  &   g | ]\}}|d kst |tr|qS state
isinstancer   ).0idxir0   r0   r1   
<listcomp>        z&Interface.__init__.<locals>.<listcomp>c                 S  rb   rc   re   )rg   rh   or0   r0   r1   rj      rk   r      zMIf using 'state', there must be exactly one state input and one state output.rd   )valuez\Cache examples cannot be used with state inputs and outputs.Setting cache_examples to False.c                 S     g | ]}t |d dqS F)renderr   rg   ri   r0   r0   r1   rj          c                 S  ro   rp   rr   )rg   rl   r0   r0   r1   rj      rt   z5 is not a valid input/output component for Interface.c                 S  s   g | ]\}}||u qS r0   r0   )rg   ri   rl   r0   r0   r1   rj     rt   c                   s   g | ]}   qS r0   )lower)rg   _r   r0   r1   rj     s    z+Invalid value for parameter: interpretation__name__r>   ZGRADIO_ALLOW_FLAGGINGmanualzThe `allow_flagging` parameter in `Interface` nowtakes a string value ('auto', 'manual', or 'never'), not a boolean. Setting parameter to: 'manual'.zThe `allow_flagging` parameter in `Interface` nowtakes a string value ('auto', 'manual', or 'never'), not a boolean. Setting parameter to: 'never'.neverautozSInvalid value for `allow_flagging` parameter.Must be: 'auto', 'manual', or 'never'.)Flag zNflagging_options must be a list of strings or list of (string, string) tuples.c                 s      | ]}t |tV  qd S N)rf   r4   rg   xr0   r0   r1   	<genexpr>^      z%Interface.__init__.<locals>.<genexpr>c                 S  s   g | ]	}d | |fqS )zFlag as r0   r   r0   r0   r1   rj   _  s    c                 s  r~   r   )rf   tupler   r0   r0   r1   r   `  r   outputzoutput NNNNNNN)Zequal_heightzClear button not renderedr0   )Vsuper__init__r\   rf   r.   DeprecationWarningr   STANDARDinterface_type
ValueError
INPUT_ONLYOUTPUT_ONLYr4   r   Zspace_idrD   	enumeratelenr   Zget_default_argsr   warningswarninput_componentsoutput_componentszipallUNIFIEDinteractivecallabler   api_moder>   Zfn_durationsgetattrrx   rH   rM   Zremove_html_tagsZsimple_descriptionrN   Zreadme_to_htmlrO   rP   rB   rK   rF   Zsimple_serverosgetenvrT   rU   rX   rW   rZ   r[   r_   shareZ	share_urlZ	local_urlZfavicon_pathr*   r+   addget_type_hintsinspectgetfullargspecismethodcopyZis_special_typed_parameterremovelabelsetuprender_title_descriptionr    render_input_columnrender_output_columnattach_submit_eventsattach_clear_eventsactivateattach_interpretation_eventsattach_flagging_eventsrender_examplesrender_articleZget_config_fileconfig)5selfr>   r?   rA   rB   rD   rF   rH   r   rK   rM   rN   rO   rP   rQ   rS   rT   rU   rW   rX   rY   rZ   r[   r\   r^   r_   r9   Zstate_input_indexesZstate_output_indexesZstate_input_indexZstate_output_indexdefaultZstate_variable	componentZsame_componentsrl   Zparam_typesZparam_names
param_nameri   
submit_btn	clear_btnstop_btn	flag_btnsduplicate_btninterpretation_btninterpretation_setinput_component_columninterpret_component_columnZsubmit_btn_outZclear_btn_2_outZstop_btn_2_outZflag_btns_out	__class__rw   r1   r   z   s  8
 

























 

@zInterface.__init__Nonec                 C  s0   | j rtd| j  d | jrt| j d S d S )N4<h1 style='text-align: center; margin-bottom: 1rem'></h1>)rM   r   rN   r   r0   r0   r1   r     s   z"Interface.render_title_descriptionlist[Button]c                 C  s   dd | j D S )Nc                 S  s   g | ]\}}t |qS r0   )r   )rg   r   rv   r0   r0   r1   rj     s    z.Interface.render_flag_btns.<locals>.<listcomp>)rU   r   r0   r0   r1   render_flag_btns  s   zInterface.render_flag_btnstuple[Button | None, ClearButton | None, Button | None, list[Button] | None, Column, Column | None, list[Interpretation] | None]c           	   	   C  s  d\}}}}d\}}t dd t  }| | jD ]}|  qW d    n1 s*w   Y  | jrXt dd}g }| | jD ]	}|t| q?W d    n1 sSw   Y  t g | jtj	tj
fv rt }| jstddd}t| js}t| jrtd	d
dd}n6| jtjkrt }tddd}t| jst| jr| jstd	d
d}| jdkr|  }n| jdkr|g}W d    n1 sw   Y  W d    n1 sw   Y  |||||||fS )N)NNNNr   panelvariantFvisibleZSubmitprimaryStopstopr   r   ry   r{   )r   r   rq   r   appendr   r    r   r   r   r   r   rH   r   r   isgeneratorfunctionr>   isasyncgenfunctionr   rT   r   )	r   r   r   r   r   r   r   r   r   r0   r0   r1   r     st   









)zInterface.render_input_columnsubmit_btn_inButton | Nonedtuple[Button | None, ClearButton | None, DuplicateButton, Button | None, list | None, Button | None]c           	   	   C  s0  |}d\}}}}}t ddz | jD ]}t|ts|  qt X | jtjkrGt	 }t
ddd}t| js=t| jrG| jsGt
dddd	}| jd
krQ|  }n| jdkra|d us^J d|g}| jrht
d}| jrrtdddd}W d    n1 s|w   Y  W d    n1 sw   Y  ||||||fS )Nr   r   r   ZGenerater   r   r   Fr   ry   r{   Submit button not renderedZ	Interpretrm   Zlg)scalesizeZ	_activate)r   r   rf   r   rq   r    r   r   r   r   r   r   r   r>   r   rH   rT   r   r   r_   r   )	r   r   r   r   r   r   r   r   r   r0   r0   r1   r   "  sL   



	


zInterface.render_output_columnc                 C  s   | j r
t| j  d S d S r   )rO   r   r   r0   r0   r1   r   ]  s   zInterface.render_articler   r   c                   s  | j ro| jtjkr3d usJ dt | jd | j j| jd | j| j	| j
 | j
 | j| jd d S | jD ]6}t|trT|jrT|j| j| j| j| j	| j
 | j
 d q6t|trl|j| j| j| j| j	| j
 | j
 d q6d S d uswJ d| j}g }jgdd | jD  }g } r g}dd }t|D ]=\}	}
|
 fdd	d  gd
dj| j| j| j|	dkr| j	nd d| j
 | j
 | j| jd	}|| |j|d |d
d q j|d  g|d
d d S t|D ]#\}	}
||
|| j| j|	dkr| j	nd d| j
 | j
 | j| jd	 qd S )Nr   )r\   
preprocesspostprocessrZ   r[   )r\   r   r   c                 S  s   g | ]
}t |tr|jqS r0   )rf   r   submit)rg   r   r0   r0   r1   rj     s    z2Interface.attach_submit_events.<locals>.<listcomp>c                   S  s   t jddt jddgS )NTr   Fr   updater0   r0   r0   r1   cleanup  s   z/Interface.attach_submit_events.<locals>.cleanupc                     s   j dd j ddfS NFr   T)r   r0   r   r   r0   r1   <lambda>  s   

z0Interface.attach_submit_events.<locals>.<lambda>F)r?   rA   r)   r   T)r\   Zscroll_to_outputr   r   rZ   r[   )r?   rA   Zcancelsr)   )rH   r   r   r   r   r'   r>   r   clickr\   r   rZ   r[   r   rf   r   Z	streamingstreamr   Zchanger   Zthenr   )r   r   r   r   r>   Zextra_outputtriggersZpredict_eventsr   ri   triggerZpredict_eventr   r   r1   r   a  s   




zInterface.attach_submit_eventsr   r   r   Column | Noner   c                 C  s   | | j| j  |jd g |r|gng | jr|gng  dt| jtj	tj
tjfv r0tjddgng | jr;tjddgng   dd d S )Nz() => Tr   Fz
            )Z_js)r   r   r   r   r   jsondumpsr   r   r   r   r   r   r   )r   r   r   r   r0   r0   r1   r     s(   
zInterface.attach_clear_eventsr   r   list[Interpretation] | Nonec                 C  s4   |r|j | j| j| j |pg ||g dd d S d S )NF)r?   rA   r   )r   interpret_funcr   r   )r   r   r   r   r   r0   r0   r1   r     s   

z&Interface.attach_interpretation_eventsr   list[Button] | Nonec                 C  s   |r| j tjtjtjfv sd S | jdkr,t| jdddd}|d j|| j	d ddd d S | j tjkr6| j	}n| j	| j
 }t|| jD ]3\}\}}t|tsOJ t| j||}|jdd d |dd	 |j|||ddd |j|jd |dd	 qBd S )
Nr{   r}   F)Zvisual_feedbackr   )r?   rA   r   r)   c                   S  s   t jdddS )Nz	Saving...F)rn   r   r   r0   r0   r0   r1   r     s    z2Interface.attach_flagging_events.<locals>.<lambda>)r)   )r   r   r   r   r   rT   r   rX   r   r   r   r   rU   rf   r4   reset)r   r   r   Zflag_methodZflag_componentsZflag_btnr   rn   r0   r0   r1   r     s^   

z Interface.attach_flagging_eventsc              
   C  sT   | j r(dd | jD }dd | jD }t| j ||| j| j| j| j| jd| _	d S d S )Nc                 S     g | ]	}t |ts|qS r0   re   rg   cr0   r0   r1   rj   3  
    
z-Interface.render_examples.<locals>.<listcomp>c                 S  r   r0   re   r   r0   r0   r1   rj   6  r   )rB   r?   rA   r>   rD   rF   r^   rZ   )
rB   r   r   r	   r>   rD   rF   r   rZ   Zexamples_handler)r   Znon_state_inputsZnon_state_outputsr0   r0   r1   r   1  s$   zInterface.render_examplesc                 C  s   |   S r   )__repr__r   r0   r0   r1   __str__D  s   zInterface.__str__c                 C  sj   d| j  }|ddt|  7 }|d7 }| jD ]	}|d| 7 }q|d7 }| jD ]	}|d| 7 }q)|S )NzGradio Interface for: 
-z
inputs:z
|-z	
outputs:)rx   r   r   r   )r   reprr   r0   r0   r1   r   G  s   

zInterface.__repr__c                   s.   |  t|I d H tjddtjddg S r   )	interpretr.   r   r   )r   argsr0   r0   r1   r   R  s
   

zInterface.interpret_func	raw_input	list[Any]c                   s(   dd t t| |I d H d |D S )Nc                 S  s   g | ]	\}}||d qS ))originalr   r0   )rg   r   Z	raw_valuer0   r0   r1   rj   Y  s    z'Interface.interpret.<locals>.<listcomp>r   )r   r   Zrun_interpret)r   r   r0   r0   r1   r   X  s   zInterface.interpretc                 C  s   t d dS )z
        Deprecated.
        z3The Interface.test_launch() function is deprecated.Nr   r   r0   r0   r1   test_launch`  s   zInterface.test_launch)r,   r-   )NNN)
r3   r4   r5   r6   r7   r6   r8   r6   r,   r   )r:   r&   r,   r*   )2r>   r   r?   r@   rA   r@   rB   rC   rD   rE   rF   rG   rH   rI   r   rJ   rK   rL   rM   r6   rN   r6   rO   r6   rP   r6   rQ   rR   rS   r6   rT   r6   rU   rV   rW   r4   rX   r   rY   rE   rZ   rI   r[   rG   r\   r]   r^   rI   r_   rI   )r,   r   )r,   r   )r,   r   )r   r   r,   r   )r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   )r   r   r,   r   )rx   
__module____qualname____doc__weakrefWeakSetr+   __annotations__classmethodr2   r'   r(   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __classcell__r0   r0   r   r1   r*   *   sh   
   
_


@;
l

7
r*   c                      s.   e Zd ZdZ					dd fddZ  ZS )TabbedInterfacez
    A TabbedInterface is created by providing a list of Interfaces, each of which gets
    rendered in a separate tab.
    Demos: stt_or_tts
    Ninterface_listr-   	tab_nameslist[str] | NonerM   r6   rQ   Theme | NonerY   rE   rS   c           	        s   t  j|pd||d|d |du rdd tt|D }| Q |r)td| d t + t||D ]\}}t|d	 |  W d   n1 sJw   Y  q2W d   n1 sZw   Y  W d   dS W d   dS 1 srw   Y  dS )
a  
        Parameters:
            interface_list: a list of interfaces to be rendered in tabs.
            tab_names: a list of tab names. If None, the tab names will be "Tab 1", "Tab 2", etc.
            title: a title for the interface; if provided, appears above the input and output components in large font. Also used as the tab title when opened in a browser window.
            analytics_enabled: whether to allow basic telemetry. If None, will use GRADIO_ANALYTICS_ENABLED environment variable or default to True.
            css: custom css or path to custom css file to apply to entire Blocks
        Returns:
            a Gradio Tabbed Interface for the given interfaces
        r`   Ztabbed_interface)rM   rQ   rY   ra   rS   Nc                 S  s   g | ]}d | qS )zTab r0   rs   r0   r0   r1   rj     s    z,TabbedInterface.__init__.<locals>.<listcomp>r   r   )r   )	r   r   ranger   r   r"   r   r!   rq   )	r   r  r	  rM   rQ   rY   rS   r%   Ztab_namer   r0   r1   r   o  s2   

"zTabbedInterface.__init__r   )r  r-   r	  r
  rM   r6   rQ   r  rY   rE   rS   r6   )rx   r   r   r  r   r  r0   r0   r   r1   r  g  s    	r  TverboserI   r,   r   c                 C  s   t  D ]}||  qd S r   )r*   r2   close)r  ior0   r0   r1   	close_all  s   r  )T)r  rI   r,   r   );r  
__future__r   r   r   r   r   r  typingr   r   r   r   Zgradio_client.documentationr   r   Zgradior	   r
   r   r   Zgradio.blocksr   Zgradio.componentsr   r   r   r   r   r   r   r   Zgradio.data_classesr   Zgradio.deprecationr   Zgradio.eventsr   r   r   Zgradio.flaggingr   r   r   Zgradio.layoutsr   r    r!   r"   Zgradio.pipelinesr#   Zgradio.themesr$   ThemeZtransformers.pipelines.baser&   r*   r  r  r0   r0   r0   r1   <module>   sB    (
      B.