import unittest

from transformers import is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_vision, slow, torch_device


if is_torch_available():
  import torch

  from transformers import AutoModelForImageClassification

if is_vision_available():
  from transformers import AutoImageProcessor




@require_torch
@require_vision
class  __magic_name__  (		unittest.TestCase    ):





   """simple docstring"""




   @slow
   def   lowerCAmelCase						(	self					:  Tuple							):



    """simple docstring"""



    _UpperCamelCase:     Dict							= AutoImageProcessor.from_pretrained('''microsoft/dit-base-finetuned-rvlcdip'''							)
    _UpperCamelCase:     Any							= AutoModelForImageClassification.from_pretrained('''microsoft/dit-base-finetuned-rvlcdip'''							)
    model.to(UpperCamelCase__							)

    from datasets import load_dataset

    _UpperCamelCase:     Dict							= load_dataset('''nielsr/rvlcdip-demo'''							)

    _UpperCamelCase:     Union[str, Any]							= dataset['''train'''][0]['''image'''].convert('''RGB'''							)

    _UpperCamelCase:     int							= image_processor(UpperCamelCase__		,  return_tensors='''pt'''							).to(UpperCamelCase__							)

    # forward pass
    with torch.no_grad():
     _UpperCamelCase:     Optional[Any]							= model(**UpperCamelCase__							)
     _UpperCamelCase:     List[Any]							= outputs.logits

    _UpperCamelCase:     Optional[int]							= torch.Size((1, 16)							)
    self.assertEqual(logits.shape		,  UpperCamelCase__							)

    _UpperCamelCase:     List[Any]							= torch.tensor(
        [-0.4158, -0.4092, -0.4347]		,  device=UpperCamelCase__		,  dtype=torch.float		,  )
    self.assertTrue(torch.allclose(logits[0, :3]		,  UpperCamelCase__		,  atol=1E-4							)							)
from __future__ import annotations

UpperCAmelCase_			    =							1.6_0_2_1E-1_9  # units = C




def       lowerCAmelCase_     (		lowercase:							float  ,					lowercase:							float  ,					lowercase:							float  ,					)    ->				tuple[str, float]:







 '''simple docstring'''
 if (conductivity, electron_conc, mobility).count(0		) != 1:
  raise ValueError('''You cannot supply more or less than 2 values'''		)
 elif conductivity < 0:
  raise ValueError('''Conductivity cannot be negative'''		)
 elif electron_conc < 0:
  raise ValueError('''Electron concentration cannot be negative'''		)
 elif mobility < 0:
  raise ValueError('''mobility cannot be negative'''		)
 elif conductivity == 0:
  return (
      "conductivity",
      mobility * electron_conc * ELECTRON_CHARGE,
  )
 elif electron_conc == 0:
  return (
      "electron_conc",
      conductivity / (mobility * ELECTRON_CHARGE),
  )
 else:
  return (
      "mobility",
      conductivity / (electron_conc * ELECTRON_CHARGE),
  )


if __name__ == "__main__":
  import doctest

  doctest.testmod()