
    biDp                     V   d dl mZ d dlmZmZmZmZ d dlZd dl	Z
d dlZd dlmc mZ d dlmZ d dl
mZ d dlmZ ddlmZ dd	lmZmZ dd
lmZ ddlmZmZmZ ddl m!Z! ddl"m#Z#m$Z$ ddl%m&Z&  e       rd dl'm(c m)Z* dZ+ndZ+ ejX                  e-      Z.dZ/ddZ0d Z1d Z2 G d de#      Z3y)    )deepcopy)CallableListOptionalUnionN)version)Image)XLMRobertaTokenizer   )__version__)UNet2DConditionModelVQModel)DDIMScheduler)is_torch_xla_availableloggingreplace_example_docstring)randn_tensor   )DiffusionPipelineImagePipelineOutput   )MultilingualCLIPTFa  
    Examples:
        ```py
        >>> from diffusers import KandinskyInpaintPipeline, KandinskyPriorPipeline
        >>> from diffusers.utils import load_image
        >>> import torch
        >>> import numpy as np

        >>> pipe_prior = KandinskyPriorPipeline.from_pretrained(
        ...     "kandinsky-community/kandinsky-2-1-prior", torch_dtype=torch.float16
        ... )
        >>> pipe_prior.to("cuda")

        >>> prompt = "a hat"
        >>> image_emb, zero_image_emb = pipe_prior(prompt, return_dict=False)

        >>> pipe = KandinskyInpaintPipeline.from_pretrained(
        ...     "kandinsky-community/kandinsky-2-1-inpaint", torch_dtype=torch.float16
        ... )
        >>> pipe.to("cuda")

        >>> init_image = load_image(
        ...     "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
        ...     "/kandinsky/cat.png"
        ... )

        >>> mask = np.zeros((768, 768), dtype=np.float32)
        >>> mask[:250, 250:-250] = 1

        >>> out = pipe(
        ...     prompt,
        ...     image=init_image,
        ...     mask_image=mask,
        ...     image_embeds=image_emb,
        ...     negative_image_embeds=zero_image_emb,
        ...     height=768,
        ...     width=768,
        ...     num_inference_steps=50,
        ... )

        >>> image = out.images[0]
        >>> image.save("cat_with_hat.png")
        ```
c                 v    | |dz  z  }| |dz  z  dk7  r|dz  }||dz  z  }||dz  z  dk7  r|dz  }||z  ||z  fS )Nr   r   r    )hwscale_factornew_hnew_ws        s/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/diffusers/pipelines/kandinsky/pipeline_kandinsky_inpaint.pyget_new_h_wr!   a   sg    q E<?a
q E<?a
<!555    c           	         g }| D ]&  }t        |      }t        |j                  d         D ]  }t        |j                  d         D ]  }|d   |   |   dk(  r|dk7  rd|d d |dz
  |f<   |dk7  rd|d d ||dz
  f<   |dk7  r|dk7  rd|d d |dz
  |dz
  f<   ||j                  d   dz
  k7  rd|d d |dz   |f<   ||j                  d   dz
  k7  rd|d d ||dz   f<   ||j                  d   dz
  k7  s||j                  d   dz
  k7  sd|d d |dz   |dz   f<     |j                  |       ) t	        j
                  |d      S )Nr   r   r   dim)r   rangeshapeappendtorchstack)masksprepared_masksmaskold_maskijs         r    prepare_maskr1   k   s   N $D>tzz!}% 	.A4::a=) .A;q>!$)6()DAE1%6()DAq1u%6a1f,-DAE1q5)

1))()DAE1%

1))()DAq1u%

1))a4::a=13D.D,-DAE1q5).	.  	d#%$& ;;~1--r"   c           
      @   | t        d      |t        d      t        | t        j                        rt        |t        j                        st	        dt        |       d      | j                  dk(  r*| j                  d   dk(  sJ d       | j                  d      } |j                  d	k(  r |j                  d      j                  d      }|j                  dk(  r5|j                  d   d
k(  r|j                  d      }n|j                  d
      }| j                  dk(  r|j                  dk(  sJ d       | j                  dd |j                  dd k(  sJ d       | j                  d   |j                  d   k(  sJ d       | j                         dk  s| j                         d
kD  rt        d      |j                         dk  s|j                         d
kD  rt        d      d||dk  <   d
||dk\  <   | j                  t        j                        } n`t        |t        j                        rt	        dt        |        d      t        | t        j                  j                  t        j                   f      r| g} t        | t"              rt        | d   t        j                  j                        r| D cg c]&  }|j%                  ||ft        j&                  d
      ( } }| D cg c]-  }t        j(                  |j+                  d            dddf   / } }t        j,                  | d      } nYt        | t"              rIt        | d   t        j                         r,t        j,                  | D cg c]  }|dddf    c}d      } | j/                  ddd
d	      } t        j0                  |       j                  t        j                        dz  dz
  } t        |t        j                  j                  t        j                   f      r|g}t        |t"              rt        |d   t        j                  j                        r|D cg c]/  }|j%                  ||ft        j                  j2                        1 }}t        j,                  |D cg c].  }t        j(                  |j+                  d            ddddf   0 c}d      }|j5                  t        j                        dz  }nZt        |t"              rJt        |d   t        j                         r-t        j,                  |D cg c]  }|ddddf    c}d      }d||dk  <   d
||dk\  <   t        j0                  |      }d
|z
  }|| fS c c}w c c}w c c}w c c}w c c}w c c}w )a  
    Prepares a pair (mask, image) to be consumed by the Kandinsky inpaint pipeline. This means that those inputs will
    be converted to ``torch.Tensor`` with shapes ``batch x channels x height x width`` where ``channels`` is ``3`` for
    the ``image`` and ``1`` for the ``mask``.

    The ``image`` will be converted to ``torch.float32`` and normalized to be in ``[-1, 1]``. The ``mask`` will be
    binarized (``mask > 0.5``) and cast to ``torch.float32`` too.

    Args:
        image (Union[np.array, PIL.Image, torch.Tensor]): The image to inpaint.
            It can be a ``PIL.Image``, or a ``height x width x 3`` ``np.array`` or a ``channels x height x width``
            ``torch.Tensor`` or a ``batch x channels x height x width`` ``torch.Tensor``.
        mask (_type_): The mask to apply to the image, i.e. regions to inpaint.
            It can be a ``PIL.Image``, or a ``height x width`` ``np.array`` or a ``1 x height x width``
            ``torch.Tensor`` or a ``batch x 1 x height x width`` ``torch.Tensor``.
        height (`int`, *optional*, defaults to 512):
            The height in pixels of the generated image.
        width (`int`, *optional*, defaults to 512):
            The width in pixels of the generated image.


    Raises:
        ValueError: ``torch.Tensor`` images should be in the ``[-1, 1]`` range. ValueError: ``torch.Tensor`` mask
        should be in the ``[0, 1]`` range. ValueError: ``mask`` and ``image`` should have the same spatial dimensions.
        TypeError: ``mask`` is a ``torch.Tensor`` but ``image`` is not
            (ot the other way around).

    Returns:
        tuple[torch.Tensor]: The pair (mask, image) as ``torch.Tensor`` with 4
            dimensions: ``batch x channels x height x width``.
    Nz"`image` input cannot be undefined.z'`mask_image` input cannot be undefined.z,`image` is a torch.Tensor but `mask` (type: z is notr   r   z2Image outside a batch should be of shape (3, H, W)r   r      z%Image and Mask must have 4 dimensionsz4Image and Mask must have the same spatial dimensionsz,Image and Mask must have the same batch sizez Image should be in [-1, 1] rangezMask should be in [0, 1] range      ?)dtypez,`mask` is a torch.Tensor but `image` (type: )resamplereducing_gapRGB)axisg     _@      ?)r8   Lg     o@)
ValueError
isinstancer)   Tensor	TypeErrortypendimr'   	unsqueezeminmaxtofloat32PILr	   npndarraylistresizeBICUBICarrayconvertconcatenate	transpose
from_numpyLANCZOSastype)imager-   heightwidthr/   ms         r    prepare_mask_and_masked_imagerZ      s   B }=>>|BCC%&$-J4PT:,V]^__ ::?;;q>Q&\(\\&OOA&E 99>>>!$..q1D 99>zz!}!~~a( ~~a(zzQ499>Z3ZZ1{{234::bc?2j4jj2{{1~A.^0^^. 99;uyy{Q?@@ 88:>TXXZ!^=>> TCZTS[ u}}-	D%,,	'FtE{mSZ[\\ eciioorzz:;GEeT"z%(CIIOO'L`ef[\QXXufoTUXVfEfBGHQRXXaii./a8HEHNN5q1Et$E!Hbjj)INN#>1AdAgJ#>QGE1a+  '***?%G#M dSYY__bjj9:6DdD!ja#))//&JSWXaAHHeV_syy7H7HHIXDX>>TX"Yq288AIIcN#;D$M#J"Y`abD;;rzz*U2Dd#
47BJJ(G>>T"B1T4]#3"BKDTCZTS[%t8D;5 gH $? Y"Y #Cs$   =+V.2V:V4V3V:Vc            %       h    e Zd ZdZdZdedededede	f
 fdZ
d	 Z	 ddZ ej                          ee      	 	 	 	 	 	 	 	 	 	 	 	 ddeeee   f   deej(                  ej,                  j,                  f   deej(                  ej,                  j,                  ej0                  f   dej(                  dej(                  deeeee   f      dedededededeeej8                  eej8                     f      deej(                     dee   deeeeej(                  gd
f      dedef"d              Z xZ S ) KandinskyInpaintPipelinea  
    Pipeline for text-guided image inpainting using Kandinsky2.1

    This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods the
    library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)

    Args:
        text_encoder ([`MultilingualCLIP`]):
            Frozen text-encoder.
        tokenizer ([`XLMRobertaTokenizer`]):
            Tokenizer of class
        scheduler ([`DDIMScheduler`]):
            A scheduler to be used in combination with `unet` to generate image latents.
        unet ([`UNet2DConditionModel`]):
            Conditional U-Net architecture to denoise the image embedding.
        movq ([`VQModel`]):
            MoVQ image encoder and decoder
    ztext_encoder->unet->movqtext_encodermovq	tokenizerunet	schedulerc                     t         |           | j                  |||||       dt        | j                  j
                  j                        dz
  z  | _        d| _        y )N)r]   r^   r_   r`   ra   r   r   F)	super__init__register_moduleslenr^   configblock_out_channelsmovq_scale_factor_warn_has_been_called)selfr]   r^   r_   r`   ra   	__class__s         r    rd   z!KandinskyInpaintPipeline.__init__  sd     	% 	 	
 "#s499+;+;+N+N'ORS'S!T%*"r"   c                     |t        ||||      }n;|j                  |k7  rt        d|j                   d|       |j                  |      }||j                  z  }|S )N)	generatordevicer7   zUnexpected latents shape, got z, expected )r   r'   r>   rG   init_noise_sigma)rk   r'   r7   ro   rn   latentsra   s          r    prepare_latentsz(KandinskyInpaintPipeline.prepare_latents$  sg    ?"5IfTYZG}}% #A'--P[\a[b!cddjj(GI666r"   Nc                 h   t        |t              rt        |      nd}| j                  |dddddd      }|j                  }| j                  |dd      j                  }	|	j
                  d	   |j
                  d	   k\  rt        j                  ||	      sj| j                  j                  |	d d | j                  j                  dz
  d	f         }
t        j                  d
| j                  j                   d|
        |j                  |      }|j                  j                  |      }| j                  ||      \  }}|j                  |d      }|j                  |d      }|j                  |d      }|r|dg|z  }nt!        |      t!        |      ur$t#        dt!        |       dt!        |       d      t        |t$              r|g}n1|t        |      k7  r!t'        d| dt        |       d| d| d	      |}| j                  |dddddd      }|j                  j                  |      }|j                  j                  |      }| j                  ||      \  }}|j
                  d   }|j)                  d|      }|j+                  ||z  |      }|j
                  d   }|j)                  d|d      }|j+                  ||z  |d	      }|j                  |d      }t        j,                  ||g      }t        j,                  ||g      }t        j,                  ||g      }|||fS )Nr   
max_lengthM   Tpt)paddingrt   
truncationreturn_attention_maskadd_special_tokensreturn_tensorslongest)rw   r{   r5   z\The following part of your input was truncated because CLIP can only handle sequences up to z	 tokens: )	input_idsattention_maskr   r$    z?`negative_prompt` should be the same type to `prompt`, but got z != .z`negative_prompt`: z has batch size z, but `prompt`: zT. Please make sure that passed `negative_prompt` matches the batch size of `prompt`.)r?   rL   rf   r_   r}   r'   r)   equalbatch_decodemodel_max_lengthloggerwarningrG   r~   r]   repeat_interleaverB   rA   strr>   repeatviewcat)rk   promptro   num_images_per_promptdo_classifier_free_guidancenegative_prompt
batch_sizetext_inputstext_input_idsuntruncated_idsremoved_text	text_maskprompt_embedstext_encoder_hidden_statesuncond_tokensuncond_inputuncond_text_input_idsuncond_text_masknegative_prompt_embeds!uncond_text_encoder_hidden_statesseq_lens                        r    _encode_promptz'KandinskyInpaintPipeline._encode_prompt/  s    %/vt$<S[!
nn "&# % 
 %....SW.Xbb  $(<(<R(@@UcetIu>>66q$..JiJilmJmprJrGr7stLNNNN334Il^M
 (**62..11&9	484E4E$Y 5F 5
11 &778MST7U%?%Q%QRgmn%Q%o"//0E1/M	&&!#z 1fT/%::UVZ[jVkUl mV~Q(  OS1!0 1s?33 )/)::J3K_J` ax/
| <33  !0>>$&*#'# * L %1$:$:$=$=f$E!+::==fEHLHYHY/@P IZ IE"$E -2215G%;%B%B1F[%\"%;%@%@NcAcel%m"7==a@G0Q0X0XYZ\qst0u-0Q0V0V22GR1-  0AABW]^A_ "II'=}&MNM).4UWq3r)s&		#3Y"?@I8)CCr"   r   rV   
mask_imageimage_embedsnegative_image_embedsr   rW   rX   num_inference_stepsguidance_scaler   rn   rq   output_typecallbackcallback_stepsreturn_dictc                    | j                   sht        j                  t        j                  t              j                        t        j                  d      k  rt
        j                  d       d| _         t        |t              rd}n3t        |t              rt        |      }nt        dt        |             | j                  }||z  }|
dkD  }| j                  |||||      \  }}}t        |t              rt        j                   |d      }t        |t              rt        j                   |d      }|rZ|j#                  |d      }|j#                  |d      }t        j                   ||gd      j%                  |j&                  |	      }t)        ||||      \  }}|j%                  |j&                  |	      }| j*                  j-                  |      d
   }|j%                  |j&                  |	      }t/        |j0                  dd       }t3        j4                  ||d      }t7        |      }||z  }|j#                  |d      }|j#                  |d      }|r(|j9                  dddd      }|j9                  dddd      }| j:                  j=                  |	|       | j:                  j>                  }| j*                  j@                  jB                  }tE        ||| jF                        \  }}| jI                  ||||f|j&                  |||| j:                        }|j0                  d   }|j0                  d   }||z   |z   | jJ                  j@                  jL                  k7  rVt        d| jJ                  j@                   d| jJ                  j@                  jL                   d| d| d| d||z   |z    d      tO        | jQ                  |            D ]  \  } }!|rt        j                   |gdz        n|}"t        j                   |"||gd      }"||d}#| jK                  |"|!||#d      d   }$|ro|$jS                  |j0                  d   d      \  }$}%|$jU                  d      \  }&}'|%jU                  d      \  }}(|&|
|'|&z
  z  z   }$t        j                   |$|(gd      }$tW        | j:                  j@                  d      r"| j:                  j@                  jX                  dv s#|$jS                  |j0                  d   d      \  }$}| j:                  j[                  |$|!||      j\                  }|,| |z  dk(  r$| t_        | j:                  dd      z  }) ||)|!|       t`        stc        jd                           | j*                  jg                  |d      d    }| ji                          |d!vrt        d"|       |d#v rX|d$z  d$z   }|jk                  dd      }|jm                         jo                  ddd%d      jq                         js                         }|d&k(  r| ju                  |      }|s|fS tw        |'      S )(a  
        Function invoked when calling the pipeline for generation.

        Args:
            prompt (`str` or `List[str]`):
                The prompt or prompts to guide the image generation.
            image (`torch.Tensor`, `PIL.Image.Image` or `np.ndarray`):
                `Image`, or tensor representing an image batch, that will be used as the starting point for the
                process.
            mask_image (`PIL.Image.Image`,`torch.Tensor` or `np.ndarray`):
                `Image`, or a tensor representing an image batch, to mask `image`. White pixels in the mask will be
                repainted, while black pixels will be preserved. You can pass a pytorch tensor as mask only if the
                image you passed is a pytorch tensor, and it should contain one color channel (L) instead of 3, so the
                expected shape would be either `(B, 1, H, W,)`, `(B, H, W)`, `(1, H, W)` or `(H, W)` If image is an PIL
                image or numpy array, mask should also be a either PIL image or numpy array. If it is a PIL image, it
                will be converted to a single channel (luminance) before use. If it is a nummpy array, the expected
                shape is `(H, W)`.
            image_embeds (`torch.Tensor` or `List[torch.Tensor]`):
                The clip image embeddings for text prompt, that will be used to condition the image generation.
            negative_image_embeds (`torch.Tensor` or `List[torch.Tensor]`):
                The clip image embeddings for negative text prompt, will be used to condition the image generation.
            negative_prompt (`str` or `List[str]`, *optional*):
                The prompt or prompts not to guide the image generation. Ignored when not using guidance (i.e., ignored
                if `guidance_scale` is less than `1`).
            height (`int`, *optional*, defaults to 512):
                The height in pixels of the generated image.
            width (`int`, *optional*, defaults to 512):
                The width in pixels of the generated image.
            num_inference_steps (`int`, *optional*, defaults to 100):
                The number of denoising steps. More denoising steps usually lead to a higher quality image at the
                expense of slower inference.
            guidance_scale (`float`, *optional*, defaults to 4.0):
                Guidance scale as defined in [Classifier-Free Diffusion
                Guidance](https://huggingface.co/papers/2207.12598). `guidance_scale` is defined as `w` of equation 2.
                of [Imagen Paper](https://huggingface.co/papers/2205.11487). Guidance scale is enabled by setting
                `guidance_scale > 1`. Higher guidance scale encourages to generate images that are closely linked to
                the text `prompt`, usually at the expense of lower image quality.
            num_images_per_prompt (`int`, *optional*, defaults to 1):
                The number of images to generate per prompt.
            generator (`torch.Generator` or `List[torch.Generator]`, *optional*):
                One or a list of [torch generator(s)](https://pytorch.org/docs/stable/generated/torch.Generator.html)
                to make generation deterministic.
            latents (`torch.Tensor`, *optional*):
                Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for image
                generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
                tensor will ge generated by sampling using the supplied random `generator`.
            output_type (`str`, *optional*, defaults to `"pil"`):
                The output format of the generate image. Choose between: `"pil"` (`PIL.Image.Image`), `"np"`
                (`np.array`) or `"pt"` (`torch.Tensor`).
            callback (`Callable`, *optional*):
                A function that calls every `callback_steps` steps during inference. The function is called with the
                following arguments: `callback(step: int, timestep: int, latents: torch.Tensor)`.
            callback_steps (`int`, *optional*, defaults to 1):
                The frequency at which the `callback` function is called. If not specified, the callback is called at
                every step.
            return_dict (`bool`, *optional*, defaults to `True`):
                Whether or not to return a [`~pipelines.ImagePipelineOutput`] instead of a plain tuple.

        Examples:

        Returns:
            [`~pipelines.ImagePipelineOutput`] or `tuple`
        z0.23.0.dev0a  Please note that the expected format of `mask_image` has recently been changed. Before diffusers == 0.19.0, Kandinsky Inpainting pipelines repainted black pixels and preserved black pixels. As of diffusers==0.19.0 this behavior has been inverted. Now white pixels are repainted and black pixels are preserved. This way, Kandinsky's masking behavior is aligned with Stable Diffusion. THIS means that you HAVE to invert the input mask to have the same behavior as before as explained in https://github.com/huggingface/diffusers/pull/4207. This warning will be suppressed after the first inference call and will be removed in diffusers>0.23.0Tr   z2`prompt` has to be of type `str` or `list` but is r<   r   r$   )r7   ro   rq   r4   Nnearest)moder   )ro   zAIncorrect configuration settings! The config of `pipeline.unet`: z	 expects z& but received `num_channels_latents`: z + `num_channels_mask`: z  + `num_channels_masked_image`: z = zT. Please verify the config of `pipeline.unet` or your `mask_image` or `image` input.)text_embedsr   F)sampletimestepencoder_hidden_statesadded_cond_kwargsr   variance_type)learnedlearned_range)rn   order)force_not_quantizer   )rv   rJ   pilzIOnly the output types `pt`, `pil` and `np` are supported not output_type=)rJ   r   r6   r   r   )images)<rj   r   parser   base_versionr   r   r?   r   rL   rf   r>   rB   _execution_devicer   r)   r   r   rG   r7   rZ   r^   encodetupler'   Finterpolater1   r   ra   set_timesteps	timestepsrg   latent_channelsr!   ri   rr   r`   in_channels	enumerateprogress_barsplitchunkhasattrr   stepprev_samplegetattrXLA_AVAILABLExm	mark_stepdecodemaybe_free_model_hooksclampcpupermutefloatnumpynumpy_to_pilr   )*rk   r   rV   r   r   r   r   rW   rX   r   r   r   rn   rq   r   r   r   r   r   ro   r   r   r   _image_shapemasked_imagetimesteps_tensornum_channels_latentssample_heightsample_widthnum_channels_masknum_channels_masked_imager/   tlatent_model_inputr   
noise_predvariance_prednoise_pred_uncondnoise_pred_textvariance_pred_textstep_idxs*                                             r    __call__z!KandinskyInpaintPipeline.__call__  s}   j ))gmmGMM+<V<c<c.dgngtgth
 /
 NNy *.D& fc"J%VJQRVW]R^Q_`aa''"77
&4s&:#7;7J7JF13NP_8
411 lD) 99\q9L+T2$)II.C$K!&'99:OUV9WL$9$K$KLagh$K$i! 99&;\%JPQRUU#))& V L
 :%VUZ[
E}226B		  '	2]])<)<V]L
EKK,-]]


 "*-
z)112GQ1O
#556KQR5S&#**1aA6J'..q!Q:L$$%8$H>>33#yy//?? '2&%AWAW&X#| &&-}lK&,,NN
 ',,Q/$0$6$6q$9!"336OOSWS\S\ScScSoSooSTXT]T]TdTdSe fII$$0011WXlWm n)):(;;[\u[v*-FFIZZ[ \JJ  d//0@AB (	DAq=XG9q=!9^e!&,>j+Y_`!a0=| \)&@"3! #  J +,6,<,<W]]1=MST,<,U)
M5?5E5Ea5H2!?(5(;(;A(>%%.?UfCf1gg
"YY
4F'GQO
 --?NN))77;WW * 0 0q1Aq 0 I
A nn))#	 * 
 k  #N(:a(? CC1g.Q(	V 		  T B8L##%11hithuvww-'CK#%EKK1%EIIK''1a399;AACE%%%e,E8O"%00r"   )N)N   r   d   g      @r   NNr   Nr   T)!__name__
__module____qualname____doc__model_cpu_offload_seqr   r   r
   r   r   rd   rr   r   r)   no_gradr   EXAMPLE_DOC_STRINGr   r   r   r@   rI   r	   rJ   rK   r   intr   	Generatorr   boolr   __classcell__)rl   s   @r    r\   r\      s   & 7+&+ + '	+
 #+ !+*	" dDL U]]_12 <@#& #%&MQ*.%*GK %p1c49n%p1 U\\399??23p1 %,,		CD	p1
 llp1  %||p1 "%T#Y"78p1 p1 p1 !p1 p1  #p1 E%//43H"HIJp1 %,,'p1 c]p1  8S#u||$<d$BCD!p1" #p1$ %p1 3 p1r"   r\   )   )4copyr   typingr   r   r   r   r   rJ   	PIL.ImagerI   r)   torch.nn.functionalnn
functionalr   	packagingr   r	   transformersr
   r   r   modelsr   r   
schedulersr   utilsr   r   r   utils.torch_utilsr   pipeline_utilsr   r   r]   r   torch_xla.core.xla_modelcore	xla_modelr   r   
get_loggerr   r   r   r!   r1   rZ   r\   r   r"   r    <module>r     s     2 2         3 ' 
 . C * ))MM			H	%+ \6.0slN10 N1r"   