





'''simple docstring'''




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   A_	(  unittest.TestCase			):




 @slow
 def      lowercase	(					self       :    Optional[int]    ):
      _UpperCAmelCase     							=   AutoImageProcessor.from_pretrained("microsoft/dit-base-finetuned-rvlcdip"    )
      _UpperCAmelCase     							=   AutoModelForImageClassification.from_pretrained("microsoft/dit-base-finetuned-rvlcdip"    )
      model.to(snake_case_    )

      from datasets import load_dataset

      _UpperCAmelCase     							=   load_dataset("nielsr/rvlcdip-demo"    )

      _UpperCAmelCase     							=   dataset["train"][0]["image"].convert("RGB"    )

      _UpperCAmelCase     							=   image_processor(snake_case_	,			return_tensors="pt"    ).to(snake_case_    )

      # forward pass
      with torch.no_grad():
           _UpperCAmelCase     							=   model(**snake_case_    )
           _UpperCAmelCase     							=   outputs.logits

      _UpperCAmelCase     							=   torch.Size((1, 1_6)    )
      self.assertEqual(logits.shape	,			snake_case_    )

      _UpperCAmelCase     							=   torch.tensor(
          [-0.4_1_5_8, -0.4_0_9_2, -0.4_3_4_7]	,			device=snake_case_	,			dtype=torch.float	,			)
      self.assertTrue(torch.allclose(logits[0, :3]	,			snake_case_	,			atol=1e-4    )    )






from __future__ import annotations

lowercase__		:Any   =    1.60_21E-19  # units = C



def        UpperCamelCase    (							lowerCAmelCase__ ,			lowerCAmelCase__ ,			lowerCAmelCase__ ,			):
					'''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()




